TI中文支持网
TI专业的中文技术问题搜集分享网站

BBxm 看门狗定时器

板子加电后子隔一段时间就会reset,发现watchdog 2是默认开启的, 定时reset,所以想关闭定时器

手册里写到:

程序运行之后定时器并没有停止工作,最终发现需要在写入寄存器之后加入空循环,让系统等待一段时间,停止定时器的命令才会生效

*reg_wdtimer2_wspr = 0x0000AAAA;
while (*reg_wdtimer2_wspr & ~0x0000AAAA){};
for (i=0; i<100; i++){};    // 空循环
*reg_wdtimer2_wspr = 0x00005555;
while (*reg_wdtimer2_wspr & ~0x00005555){};
for (i=0; i<100; i++){};

但手册里并没有提到这一点, 也不知道到底应该等多久

有没有什么更好的办法关闭定时器?

我也试着关闭iclk和fclk, 但似乎不起作用

Zhiwen He:

还有个问题是看门狗关闭之后修改参数再重新开启,代码如下,用过用xds100v2逐行调试的时候没有问题,但存到sd卡在板子上就运行不了, uart也不输出, 如果只保留关闭看门狗的代码, 注释掉修改参数和开启看门狗的代码, 程序在板子上就能正常运行, 请问这又是为什么?

// disable watchdog 2 uart_write("Turn off watchdog 2…"); *reg_wdtimer2_wspr = 0x0000AAAA; for (i=0; i<100; i++){}; // It takes sometime to make the change on register. while (*reg_wdtimer2_wspr & ~0x0000AAAA){}; for (i=0; i<100; i++){}; *reg_wdtimer2_wspr = 0x00005555; while (*reg_wdtimer2_wspr & ~0x00005555){};/* *reg_wdtimer2_wldr = 0x0;// *reg_wdtimer2_wtgr = 0xFFFFF000;

// enable watchdog 2 uart_write("Turn on watchdog 2…"); *reg_wdtimer2_wspr = 0x0000BBBB; for (i=0; i<100; i++){}; // It takes sometime to make the change on register. while (*reg_wdtimer2_wspr & ~0x0000BBBB){}; *reg_wdtimer2_wspr = 0x00004444; for (i=0; i<100; i++){}; while (*reg_wdtimer2_wspr & ~0x00004444){};

Tony Tang:

回复 Zhiwen He:

while检查搞错寄存器了,是要检查WDT_WWPS[W_PEND_WSPR],直到为0(no pending)再往下走。

20.4.3.8 Start/Stop Sequence for Watchdog Timers (Using the WDT_WSPR Register)To start and stop a watchdog timer, access must be made through the start/stop register (WDT_WSPR)using a specific sequence.To disable the timer, follow this sequence:1. Write XXXX AAAAh in WDT_WSPR.2. Poll for posted write to complete using WDT_WWPS.W_PEND_WSPR.3. Write XXXX 5555h in WDT_WSPR.4. Poll for posted write to complete using WDT_WWPS.W_PEND_WSPR.

To enable the timer, follow this sequence:1. Write XXXX BBBBh in WDT_WSPR.2. Poll for posted write to complete using WDT_WWPS.W_PEND_WSPR.3. Write XXXX 4444h in WDT_WSPR.4. Poll for posted write to complete using WDT_WWPS.W_PEND_WSPR.All other write sequences on the WDT_WSPR register have no effect on the start/stop feature of themodule.

Zhiwen He:

回复 Tony Tang:

谢谢回复

赞(0)
未经允许不得转载:TI中文支持网 » BBxm 看门狗定时器
分享到: 更多 (0)