This post describes the watchdog timer.
What is a watchdog timer?
A watchdog timer (WDT: Watchdog Timer) is a timer with an automatic reset function used in embedded and computer systems.It checks that the system is operating normally and automatically resets when an abnormality occurs, thereby improving system stability.
How WDT works
The WDT is a timer that, when enabled, starts counting for a fixed period of time (timeout period). The program periodically “clears the WDT” to reset the count and restart the WDT (this is also called “kicking the watchdog”). When WDT times out, it is determined that a system error has occurred and a reset signal is sent to the reset function of the MCU.
Recently, there is another type that sends a reset signal if it does not kick in within a window (within Time Min to Time Max) in addition to the timeout.
There are two types of WDT: an MCU-built-in WDT and an external WDT.
Advantages | Disadvantages | |
---|---|---|
MCU-built-in WDT | – No additional costs. – Easily implemented in software. – Space-saving. – Low power consumption. | – May not function if MCU is completely frozen*. – Less certainty of reset compared to external*. – May be disabled due to misconfiguration or software bugs. |
External WDT | – Functions even if MCU is completely frozen. – MCU can also be monitored. – Various actions can be configured, including not only sending a reset signal but also forcibly shutting off the power supply and saving an abnormality log. | – Additional costs. – Board becomes more complex. – Using the MCU’s GPIOs. – Increased power consumption. |
* Some MCUs are taking measures.

Notes on WDT
The WDT requires attention to the following:
- Disable WDT if necessary, as WDT reset may occur depending on the debugging method.
- The program kick process should be executed with the lowest priority.
If kick processing is performed in a higher priority process, WDT may not be able to detect an anomaly, such as an infinite loop, in a lower priority process. - If an external WDT is used, the WDT should be kicked in at a fixed cycle during repro.