What is a Watchdog Timer?

OutlineImagine yourself as a stranger at your newly-made friend\'s dooryard, to stop the vicious watchdog from "barking" and "biting", you have to "feed" the watchdog ...

author avatar

0 Followers

Outline

Imagine yourself as a stranger at your newly-made friend\'s dooryard, to stop the vicious watchdog from "barking" and "biting", you have to "feed" the watchdog or "kick" it, at regular intervals.

So what is a watchdog timer used for? Very simply, a watchdog timer (or a watchdog/COP timer) is to detect (and send alert) whether there are malfunctions in a processing computer. If corrections aren\'t provided in time, the watchdog timer would signal a RESET instruction to the system which usually triggers a computer restart. Thereby, the potential hang-up or crash of a system is ceased.

In the past, programming without a watchdog had caused great property lost and risked human life. In 1994, a Moon observation project underwent a software exception which results in the everlasting rotation of a thruster, which finally caused the fuel to run out and fail the whole mission.

Different Configurations of Watchdog Timers

In this section, we\'ll show you exactly how a watchdog timer (WDT) performs in different configurations.

- Single-Staged Watchdog

Regarding this configuration, a system clock is applied to both the computer and the watchdog timer as the diagram depicted above. While other WDTs may use an independent clock device, they share the same operating principle that once the clock counts down to a certain value (Time Out) the watchdog timer asserts RESET to the computer. 

If the computer operates normally, it\'ll send a RESTART instruction (kicking the dog) to the WDT as the clock starts to count down from the beginning.

- Multistage Watchdog

As shown in the diagram above, a set of timers (time stages) piled up to form a chain-reacting 3-stage WDT. Every time Stage1 or Stage2 times out, corrective action is triggered and the subsequent stage is reached. As soon as the stage3 times out, the watchdog timer asserts RESET to the computer, setting of a computer restart.

- NMI Watchdog

An NMI Watchdog is a bit like a multi-stage watchdog. It technically contains 2 time stages, between which a non-maskable interrupt (NMI) is sent to the computer. The NMI is used to notify the computer that a reset is approaching and then the computer may store the stack and debugging information into a region of non-volatile memory for developers to access lately.

Internal & External Watchdog Timers

- Internal Watchdog Timers

In nowadays computer program practices, almost all the microcontrollers (MCUs) have watchdog peripherals integrated. Some of them may include more than one WDT of different configurations. Utilizing an internal watchdog can save a lot of costs, but it may be contaminated by runaway codes. Compared to an external watchdog timer, it is easy to use and less sensitive to temperature.

- External Watchdog Timers

Another kind of WDT is a stand-alone IC embedded in a system. Since it can\'t be affected by runaway code as an internal WDT does (if well-deployed) so it is said to be a safer type. Plus, external watchdog timers can monitor the VCC power supply, too. What\'s more, because of the MCU\'s method to save power, its timeout setting must be calculated to match both high and low-speed clock modes.

Difference between Independent & Window Watchdog Timers

- Independent Watchdog Timers (IWDT)

 

As opposed to a window watchdog timer, an independent watchdog timer is called a non-windowed watchdog timer too. As mentioned before, it is simply a down-counting timer; when it counts to zero, it sends a reset signal to the computer. 

•It operates with an RC oscillator of about 40 kHz internal to it•It has a 12-bit down-counter•It only has a floor level•It has hardware version as well as software version•It cannot generate interrupts as a window watchdog timer•It is often implemented to monitor hardware malfunctions for the reason that it relies on an independent clock and runs outside the main application

- Window Watchdog Timers (WWDT)

A WWDT is distinctive from an IWDT in the way it determines whether the computer should be restarted. It uses a "window" to limit the time for kicking the dog; kicks have to occur within the window (green zone in the diagram below) or they are recognized to be malfunctions then the reset instruction would be triggered.

•It operates with the clock that is shared with the system•It has a 7-bit down-counter•It has a floor level and an upper bound•It is merely controlled by software•Not like an IWDT, it may generate interrupts before resetting that remind the computer •It is often implemented to detect a software fault for it uses a shared clock with the system

- Calculation of Kicking Time of IWDT & WWDT

·IWDT

Tout=(4×2PRER×rlr)/32

·WWDT

Twwdg=(4096×2WDGTB×(T[5:0]+1))/RCCPCLK3

Selecting Watchdog Timers

For selecting watchdog timers, Easybom got several hints for you based on what we have just discussed.

- If your project requires higher timing accuracy, you\'d better purchase microcontrollers with WWDT integrated.

- It\'s always recommended to apply an external WDT to add a layer of safety if you have a bigger budget.

- Backed up WWDG with an IWDG that has a much longer period set than the WWDG.

That\'s all for today\'s sharing. We hope this may help you with your project!

Originally published on EASYBOM blog

Top
Comments (0)
Login to post.