What's a watchdog timer?
Simply put, you can think of it as a watchdog for your home...? That is to say, it's a function that monitors something and fixes errors when anomalies occur.
It plays a role in monitoring whether an MCU (Microcontroller Unit) is stuck in uncontrollable situations like an infinite loop or abnormal stop situations.
It's the minimum device that ensures an MCU operates properly when it encounters abnormal situations.
The principle is as follows:
The watchdog timer periodically monitors the CPU, and if the CPU fails to receive input for a certain period of time, it determines that the CPU is abnormal and proceeds with a reset.
* Kick: Signal indicating that the CPU is operating normally
* Reset: Initialize CPU in abnormal situations.
There are three modes in watchdog operation.
- Timeout Mode: In Timeout Mode, if the watchdog timer does not receive a signal from the MCU within a set period of time, it assumes that the MCU is malfunctioning and outputs a reset signal. For example, when a program is not completed or fails to respond within a specified time, the watchdog timer expires and resets the system. This mode is primarily used to prevent the system from getting stuck in an infinite loop or halting due to unexpected issues. However, Timeout Mode has a drawback: it cannot detect errors that cause double pulses within the set period.
- Window Mode: Window Mode is introduced to address the drawback of Timeout Mode. In Window Mode, if the watchdog timer does not receive a signal from the MCU or receives a double pulse from the MCU within the set period, it determines that the MCU is malfunctioning and outputs a reset signal. This mode is mainly used in real-time systems where specific tasks need to be completed within a certain time.
- Question and Answer (Q&A) Mode: Q&A Mode allows for more accurate fault detection than the two previous modes because it utilizes data communication between the MCU and the watchdog timer. In this mode, the MCU sends pre-configured data to the WDT, and the WDT determines whether the received signal matches the pre-configured data to judge if the MCU is operating correctly. In Q&A Mode, when the watchdog timer expires, instead of resetting the system, it performs specific actions that should be handled by the processor.
The ranking of error detection accuracy in these modes is Timeout Mode → Window Mode → Q&A Mode.
These modes are selected and configured considering the requirements and safety of the system.
The reason for using watchdog timers lies in the frequent occurrence of situations where embedded systems encounter problems that cannot always be resolved by human intervention. For instance, in critical situations in automotive systems, spacecraft systems flying into space, or systems controlled remotely, it is essential to quickly restore normal operation.
To put it simply, when a PC freezes or encounters a blue screen, the most rational solution is to reboot at that moment. Similarly, the role of watchdog timers is to automatically recover the system when such situations occur, thereby necessitating the creation of functionalities like watchdog timers.
In recent times, there has been an increasing demand for safety in electronic devices. Consequently, the automotive industry, where numerous electronic devices are integrated, is becoming more stringent in terms of safety compared to the past. Therefore, studying safety-related technologies such as watchdog timers is deemed necessary.