What is Watchdog timer?

A timer that resets the microcontroller if software does not kick it within a set time, recovering from runaway or hung programs.

Field: Embedded Systems & Firmware

Japanese name: ウォッチドッグタイマ

How a watchdog works

A watchdog is a down-counter that runs independently of the program it supervises. Software must periodically "kick", "feed" or "service" it, typically by writing a specific key value to a register, which reloads the counter. If the counter reaches zero because the code has hung in a loop, crashed into a fault handler or been upset by noise, the watchdog asserts a reset (on some parts, first an early-warning interrupt) and the microcontroller restarts from a known state. Clocking it from its own low-speed oscillator means a failed main clock does not silence it as well.

Where to kick it

A watchdog is only as good as the place where it is kicked. Kicking it unconditionally inside a periodic timer interrupt is a classic mistake: the interrupt keeps firing even when the main loop is stuck, so the counter never expires and the hang goes unnoticed. A better pattern has each task or main-loop stage set a check-in flag, and a supervisor routine kicks the watchdog only when every flag has been set within the period, then clears them. The timeout is chosen longer than the worst-case loop time but short enough to bound recovery time.

Window watchdog vs. standard watchdog

A standard watchdog only catches kicks that arrive too late. If a fault makes the program skip most of its work and spin in a short loop that still contains the kick, the timer is serviced more often than expected and nothing is detected. A window watchdog adds a lower bound: kicks are accepted only inside a defined time window, and a kick that comes too early is treated as a fault just like a missing one. This catches control-flow errors that a simple timeout misses, which is why window watchdogs are common in functional-safety designs.

External watchdogs in safety systems

In automotive and industrial equipment the watchdog is often placed in a separate supervisor or power-management IC running on its own clock, so a common cause such as a failed oscillator cannot stop both the processor and its monitor. Some external monitors use question-and-answer schemes in which the processor must return the correct response to a challenge within a time window. After a watchdog reset, firmware usually reads a reset-cause register so the event can be logged and analyzed instead of silently repeating.

Try it: questions about Watchdog timer

Which correctly describes a feature of a window watchdog timer?

  1. AOnce kicked, it stops monitoring to reduce power consumption
  2. BIt detects as an anomaly not only kicks (timer clears) that come too late relative to a defined time window but also kicks that come too early
  3. CWhen a kick is late, it assumes the program is doing heavy processing and, without resetting, automatically extends the wait time to let processing continue
Show answer and explanation

Answer: B. It detects as an anomaly not only kicks (timer clears) that come too late relative to a defined time window but also kicks that come too early

An ordinary watchdog issues a reset if it is not kicked within a certain time. However, in anomalies where the program skips part of its processing and runs in a short loop, kicks arrive early and may go unnoticed. A window watchdog defines a time window in which kicking is allowed and treats kicks that are too early or too late as anomalies. In automotive systems, the watchdog is sometimes placed in an external monitoring IC running on a clock separate from the microcontroller, so that a common cause does not stop both.

What is the role of the watchdog timer built into microcontrollers?

  1. ADisplaying the accurate time
  2. BRaising the clock frequency
  3. CResetting the system if the program runs away and fails to clear the timer within a set time
Show answer and explanation

Answer: C. Resetting the system if the program runs away and fails to clear the timer within a set time

A watchdog timer expects healthy software to reset it periodically; if a crash or hang lets it expire, it resets the microcontroller. This allows automatic recovery without human intervention after noise or unexpected states, which is essential in automotive, industrial and remote equipment. Running it from an independent clock, or using a window watchdog that also treats too-early resets as faults, improves reliability.

FAQ

What does it mean to kick or feed a watchdog timer?

It means writing to the watchdog's reload or service register so its counter restarts before it expires. Healthy software does this periodically; if it stops doing so, the watchdog resets the chip.

Should I kick the watchdog inside a timer interrupt?

Not unconditionally. A timer interrupt keeps running even when the main code is hung, so it would hide the fault; kick only after confirming that the main loop and each task have completed a normal cycle.

What is the difference between a window watchdog and a normal watchdog?

A normal watchdog resets only when the kick comes too late. A window watchdog also treats a kick that arrives too early as a fault, catching code that is looping abnormally fast.

Questions that mention Watchdog timer (1)

Watchdog timer appears in 3 practice questions across 3 topics, including Automotive Semiconductors and Functional Safety, CPUs and architecture, Embedded Systems & Firmware.

  1. Why is it bad practice to kick (reset) the watchdog timer unconditionally inside a 1 ms timer interrupt handler?

Books on Embedded Systems & Firmware Ad

Learn hands-on: parts and kits

Building real circuits is a good way to check what you learned in the questions.

As an Amazon Associate I earn from qualifying purchases.

This page was drafted with AI and fact-checked by a separate AI review before publication. Our Editorial policy explains how we write and check content. If you spot an error, please tell us on our Contact page.

Back to the glossary