程序代码如下
#include "s5pc100.h"
typedef struct {
unsigned int WTCON;
unsigned int WTDAT;
unsigned int WTCNT;
unsigned int WTCLRINT;
}watchdog;
#define WATCHDOG (*(volatile watchdog *)0XEA200000)
void watchdog_unit()
{
printf("flag1\n");
WATCHDOG.WTDAT = 0XFFFF;
WATCHDOG.WTCON = (0XFF<<8 | 1<<5 | 1<<3 | 0<<2 | 1);
printf("flag3\n");
WATCHDOG.WTCNT = 0XFFFF;
printf("in watchdog\n");
}
int main(void)
{
watchdog_unit();
}
为什么该程序会在watchdog_unit();函数中一直执行。
如果在watchdog_unit();语句后加上while死循环,看门狗正常工作
int main(void)
{
watchdog_unit();
while(1);
}