nuvoton - M451 Window Watchdog Timer
Window Watchdog Timer 特性
- 6 bits 下數計數器和比較器
- 16 selections window watchdog timer 預除器
- Only one time to set windows watchdog timer controller after chip power-on or reset.
- Watchdog Timer 和 Window Watchdog Timer share a single IRQ handler
- 支援 window watchdog timer interrupt
- 支援 window watchdog timer reset
Window Watchdog Timer Clock Source
- HCLK0 / 2048
- LIRC (10 KHz)
- LXT (32.768 KHz)
Window Watchdog Timer Block Diagram
- 11-bit prescale controlled PSCSEL (WWDT_CTL[11:8])
- 當 CNTDAT = CMPDAT,就會產生 WWDT interrupt。而且當 CNTDAT <= CMPDAT時,設定 WWDT_RLDCNT = 0x5AA5,CNTDAT 就會重新載入 0x3F.
- 當 CNTDAT 繼續下數到 0 時,會產生 MCU reset。
- 當 CNTDAT > CMPDAT,設定 WWDT_RLDCNT = 0x5AA5,就會產生 MCU 的 reset。
Window Watchdog Timer Function
- WWDT Counting
- WWDTEN (WWDT_CTL[0]) = 1, WWDT down counter from 0x3F to 0x00.
- WWDT_CTL written once after chip is powered on or reset.
- WWDTEN (WWDT_CTL[0]) enabled
- WWDT counter can't disable
- Counter Prescale Period (PSCSEL) can't change
- Window Compare Value (CMPDAT) can't change
- WWDT Compare Math Interrupt
- WWDTIF (WWDT_STATUS[0]) = 1, WWDT counter value (CNTDAT) equal window compare value (CMPDAT).
- WWDTIF = 1, WWDT compare match interrupt
- WWDT Reset System
- 6-bit down counter (CNTDAT) 和 6-bit compare (CMPDAT) 比較
- CNTDAT > CMPDAT : write RLDCNT = 0x5AA5 to reset system
- CNTDAT =0 : if not write RLDCNR = 0x5AA5, reset system
- CNTDAT <= CMPDAT : write RLDCNT = 0x5AA5 to reload CNTDAT to 0x3F
- WWDT Window Setting Limitation
- WWDT_RLCNT = 0x00005AA5 to reload WWDT counter to 0x3F (need 3 clocks)
- WWDTIF (WWDT_STATUS[0]) =1 when WWDT reset system event.
範例程式 :
在 FreeRTOS 中,加入一個 Task 來完成 Window Watchdog 中斷比較耗時的工作,平常 Task 位於 Suspend 的狀態,等 Window Watchdog 計算到 CNTDAT 和 CMPDAT 相等時,產生中斷,重新載入 CNTDAT 計時值,等到第6次中斷產生,沒有重新載入 CNTDAT 計數值,而是讓 CNTDAT 計數器計數到零,產生 Window Watchdog Timeout 中斷 reset MCU.
範例程式位於 Github 的 nuvotoon-M451-Sample 的 FreeRTOS-WWatchdog-Sample branch
- nuvoton NuMicro-M451-Series-Training-Material
- nuvoton TRM_M451_Series_EN_Rev2.08
留言
張貼留言