The watchdog timer (WDT, WatchDogTImer) is an integral part of the microcontroller. It is actually a counter, which generally gives the watchdog a number. After the program starts running, the watchdog starts counting down. If the program is running normally, the CPU should issue a command to reset the watchdog and restart the countdown. If the watchdog is reduced to 0, it is considered that the program does not work properly, forcing the entire system to reset.
working principle
When used, the WDT will increment until overflow, or "time out." Unless in Sleep or Idle mode, a WDT time-out will force a device Reset. To avoid a WDT time-out reset, the user must periodically clear the watchdog timer with the PWRSAV or CLRWDT instruction. If the WDT times out in Sleep or Idle mode, the device wakes up and resumes code execution from where the PWRSAV instruction was executed. In both cases, the WDTO bit (RCON "4") will be set to indicate that the device reset or wake-up event was due to a WDT time-out. If the WDT wakes up the CPU from Sleep or Idle mode, the "Sleep" status bit (RCON "3") or the "Idle" status bit (RCON "2") is also set to indicate that the device was previously in power saving mode.
During normal operation, a WDT time-out overflow will generate a device reset. When the device is in a sleep state, a WDT time-out overflow will wake up the device and continue normal operation (known as WDT wake-up). Clearing the WDTE set bit permanently turns off the WDT.
The postscaler assignment is completely software controlled, ie it can be changed at any time during program execution.
To avoid unpredictable device resets, the following instruction sequence must be executed when changing from the TImer0 prescaler assignment to the WDT postscaler assignment. Even if the WDT is disabled, this instruction sequence is executed.
PIC WatchdogPIC series of different types of microcontrollers, watchdog settings are different, the following is a PIC16F688 microcontroller as an example.
1. If WDTE = 1 in the configuration word, then the watchdog switch (WDT) does not work, so our watchdog will always overflow when we have sleep mode, but it will reset after overflow. To see the specific type of the MCU, the PIC16F688 continues to execute the program after it wakes up and does not reset, but other MCUs look at the manual. If we don't need a watchdog when sleeping in the program, then we must turn off the watchdog and don't forget to open the watchdog when we wake up.
2. The one-stage frequency division of the one-chip computer is used with TIME0 mutually, can only use one side at the same time.
If we choose the internal 4M clock and we pre-divide the timer TIME0, then our watchdog maximum time is 0.262144s. Then we use the timer 0 to feed the dog, and the time for our timer 0 interrupt must be less than 0.262144
Otherwise we will reset
Rongchang Group supports you all the solar system products including the cables,solar pv bracket,connectors and all others in need.
Solar Pv Cable,Solar Pv Bracket ,Mc4 Branch Connector,Dc Tv
NANTONG RONGCHANG IMPORT&EXPORT CO.,LTD , https://www.ergsolarcn.com