Hi, I'm Duck.
During a training session on microcontrollers, the concept of a watchdog timer came up.
A watchdog timer is essentially a guardian of the CPU, which is the core of a microcontroller. It is commonly incorporated into microcontrollers and other devices.
Arm® systems also include a watchdog timer, and it can also be used with Altera's Nios® II (softcore processor).
What is a watchdog timer?
A watchdog timer monitors whether the system is functioning correctly.
It checks whether the CPU and other components are functioning correctly. Of course, if it detects an abnormality, it will respond accordingly.
Figure 1. What is a watchdog timer?
Monitoring system
So, how do they check it?
The watchdog timer counts down a set period of time, during which the CPU periodically resets the counter.
If the counter is not reset and the count value exceeds a certain value, an abnormality will be indicated.
Figure 2. How the watchdog timer works.
The actions to be taken when no signal is detected for a certain period of time are predetermined. The watchdog timer is what initiates those actions.
It doesn't have to be the exact same time every time, as long as you can reset it within the time limit.
The normal operation and the operation in the event of an abnormality are as follows:
Figure 3. Operation during normal operation and when an abnormality occurs.
In the example of operation when an anomaly occurs in Figure 3, if no signal is received from the CPU for a certain period of time, the watchdog timer sends a signal to indicate an anomaly. Upon receiving this signal, the CPU then performs initialization.
The CPU is the heart of the microcontroller. If the CPU doesn't function properly, the entire system will not work correctly.
The watchdog timer plays a crucial role in alerting us if something has happened to the CPU.
Things to remember +α
The watchdog timer is usually disabled when debugging.
This is because if you are not operating at a normal speed, such as during step-by-step execution, the watchdog timer will consider this an anomaly and cause the CPU to reset.
If you look at the debug source code, you should find the code to stop the watchdog timer near the beginning.