程序代码如下
#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);
}
watchdog_unit函数是顺序执行的,没有什么循环,执行完了就结束了
你是怎么判断程序一直在该函数中执行的
不知你是都处理好了裸机开发的启动问题
没有一直执行 不加while CPU会在执行完wathdog之后去他下面的指令 这个指令是随机数 会使CPU进入到fetch中断 死在里面
确定你的程序在使用printf函数之前,假如printf是打印到串口的,就要首先初始化串口,否则就有可能死在printf中。
还有你的初始化看门狗寄存器顺序是否正确都有可能。