程序代码如下
#include "s5pc100.h"
typedef struct {
unsigned int WTCON;3 x- R- l1 S( y+ j: H: [* p1 m
unsigned int WTDAT;$ m4 z) ~% ]; H9 B3 m) d; Z
unsigned int WTCNT;
unsigned int WTCLRINT;# f% E- }; L% Q/ X5 Z
}watchdog;9 h9 e2 y6 A0 ]2 H" r: f
#define WATCHDOG (*(volatile watchdog *)0XEA200000)
void watchdog_unit()& J E9 [' a- {
{
printf("flag1\n");
WATCHDOG.WTDAT = 0XFFFF;' _& L, ~! y$ G( c1 O
WATCHDOG.WTCON = (0XFF<<8 | 1<<5 | 1<<3 | 0<<2 | 1);5 S/ M: {: K; v9 o, z# d6 ~5 f0 B. k
printf("flag3\n");" _. ?5 \& L3 h* S
WATCHDOG.WTCNT = 0XFFFF;2 T) ]- O5 L5 j
printf("in watchdog\n");
}
int main(void)
{
watchdog_unit();
}
为什么该程序会在watchdog_unit();函数中一直执行。
5 F( i G8 {5 t7 A- I
如果在watchdog_unit();语句后加上while死循环,看门狗正常工作
int main(void)
{0 V+ L4 R7 D+ `3 D4 |& {7 E% C4 |
watchdog_unit();
while(1);
}
| 欢迎光临 EDA365电子论坛网 (https://bbs.eda365.com/) | Powered by Discuz! X3.2 |