虽然使用LCP21XX 很长时间,但一直没有使用内部看门狗,这次我看门狗打开了,却发现经常导致复位,经过调试,锁定是内部看门狗搞鬼,反复测试发现是因为在喂狗的两条语句,如下:
WDFEED = 0xAA;
WDFEED = 0x55;
受到到中断影响,导致两条语句执行的时间增长,内部认为FEEDWDT 错误。
下面是DATASHEET中的描述:
4.3 Watchdog Feed register (WDFEED - 0xE000 0008)
Writing 0xAA followed by 0x55 to this register will reload the watchdog timer to the WDTC
value. This operation will also start the watchdog if it is enabled via the WDMOD register.
Setting the WDEN bit in the WDMOD register is not sufficient to enable the watchdog. A
valid feed sequence must first be completed before the Watchdog is capable of
generating an interrupt/reset. Until then, the watchdog will ignore feed errors. Once 0xAA
is written to the WDFEED register the next operation in the Watchdog register space
should be a WRITE (0x55) to the WDFFED register otherwise the watchdog is triggered.
The interrupt/reset will be generated during the second PCLK following an incorrect
access to a watchdog timer register during a feed sequence.
应该提示 write 0xaa & write 0x55 之间的最短的时间要求,这样的使用者更清晰、更容易的使用这个东东。 |