watchdog的理解在lh7a404

我的cpu是lh7a404

watchdog主要有兩個寄存器

Control register(CTL) 和 Reset register (RST)

 

如果重新上電, CTL initial value is 0. If we write data 0x01, 0x91, what will happen??

It will reboot at once. Because its counter is 0, when counter is 0, watchdog reboot.

如果爲了避免重啓,首先設置TOC, the maximum value is 1111, such as 0xf(0-f), its bit is from (4-7).

Then set RST register, 使得TOC時間不要太短, RST的唯一功能就是更新TOC

接着,使能 CTL第0位,

 

physAddr_write(WDT_BASE + WDT_CTL, 4, 0xf0) //設置最長的timeout

physAddr_write(WDT_BASE + WDT_RST, 4, WDT_RST_CONST); //reset counter

physAddr_write(WDT_BASE + WDT_CTL, 4, WDT_CTL_EN);  // enable watchdog, it start work.

 

如果這樣做了,重新上電啓動,沒有問題,

 

在串口輸入:reboot, 按Ctrl+C進入bootloader模式,過了一會兒,板子重啓了。

爲什麼?

reboot, 沒有斷電,watchdog is still work, so when counter result is get 0. so it will reboot.

重啓時,watchdog不再工作了,所以再按Ctrl+C,它也不會重啓了。

所以需要更新bootloader的代碼消除這個現象。我就不做了。

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章