Watchdog Timer Calculator
Calculate watchdog timeout from oscillator frequency, prescaler and reload count, or find the closest watchdog prescaler and reload settings for a target timeout. Inspect watchdog tick rate, timeout error and recommended refresh intervals.
Timeout = Counts × Prescaler / Watchdog Clock.
If the watchdog reload register is zero-based, use
Counts = Reload + 1. Some MCU watchdogs have additional fixed
dividers, window restrictions or oscillator tolerances, so verify the final
register interpretation against the MCU reference manual.
—
What Is a Watchdog Timer?
A watchdog timer is a hardware timer used to detect software that has stopped operating correctly. Application code periodically refreshes or services the watchdog. If that refresh does not occur before the timeout expires, the watchdog can generate a reset, interrupt or other recovery action.
The timeout is commonly derived from a low-speed oscillator, prescaler and counter or reload value.
Watchdog Timer Timeout Formula
Timeout =
Counter Counts × Prescaler Divider
----------------------------------
Watchdog Source ClockIf the reload register is zero-based, the number of counts is typically reload plus one.
Watchdog Clock After Prescaler
Watchdog Tick Frequency =
Source Clock
------------
PrescalerFor a 32 kHz source and divide-by-32 prescaler, the watchdog counter receives a 1 kHz clock.
32 kHz Watchdog Example
Source Clock:
32,000 Hz
Prescaler:
32
Tick:
32,000 / 32
= 1000 Hz
Reload:
999
Counts:
1000
Timeout:
1000 / 1000
= 1 secondWatchdog Reload Value
The reload value defines how many watchdog counter ticks can occur before the timeout event. On a zero-based watchdog counter, a register value of 999 corresponds to 1000 counts.
Reload:
999
Counts:
999 + 1
= 1000Watchdog Prescaler
The prescaler slows the watchdog oscillator before it reaches the counter. Larger prescaler values increase the possible timeout but reduce the timing resolution of the watchdog counter.
| Clock | Prescaler | Watchdog Tick |
|---|---|---|
| 32 kHz | 4 | 8 kHz |
| 32 kHz | 8 | 4 kHz |
| 32 kHz | 16 | 2 kHz |
| 32 kHz | 32 | 1 kHz |
| 32 kHz | 64 | 500 Hz |
| 32 kHz | 256 | 125 Hz |
Watchdog Tick Period
The watchdog tick period is simply the reciprocal of the watchdog tick frequency.
Tick Frequency:
1000 Hz
Tick Period:
1 / 1000
= 1 msFinding a Reload Value from a Target Timeout
If the watchdog clock and prescaler are known, the required count is:
Required Counts =
Target Timeout × Source Clock
-----------------------------
PrescalerThe result must be converted to an integer counter value supported by the hardware.
Watchdog Counter Width
| Counter Width | Maximum Register | Zero-Based Counts |
|---|---|---|
| 8-bit | 255 | 256 |
| 12-bit | 4095 | 4096 |
| 16-bit | 65,535 | 65,536 |
| 24-bit | 16,777,215 | 16,777,216 |
| 32-bit | 4,294,967,295 | 4,294,967,296 |
Watchdog Refresh Interval
Software normally refreshes the watchdog well before its timeout boundary. For a non-windowed watchdog, scheduling the refresh around a fraction of the timeout can provide margin for execution delays.
Watchdog Timeout:
2 seconds
50% point:
1 second
75% point:
1.5 secondsThe correct refresh strategy depends on the application’s worst-case timing and whether the watchdog includes a minimum refresh window.
Window Watchdog vs Independent Watchdog
A basic independent watchdog typically requires servicing before a maximum timeout. A window watchdog can additionally reject servicing that occurs too early.
This calculator handles the fundamental timeout, prescaler and reload mathematics. A dedicated window calculation also requires the watchdog’s minimum allowed refresh point.
Watchdog Oscillator Tolerance
Many watchdog timers use low-speed internal oscillators whose frequency can have significant tolerance across voltage and temperature. A nominal 32 kHz watchdog source may therefore not operate at exactly 32,000 Hz on every device.
For safety-critical timeout design, calculate both the fastest and slowest possible timeout using the oscillator limits from the microcontroller datasheet.
Watchdog Timeout Error
When finding settings for a requested timeout, integer reload values and a limited set of prescaler dividers can prevent an exact match.
Error =
Actual Timeout - Target TimeoutThe calculator tests all supplied prescaler choices and chooses the closest valid result.
Watchdog Timer Calculator FAQs
How do I calculate watchdog timeout?
What does a watchdog prescaler do?
Why does reload sometimes use +1?
What is a watchdog refresh?
What happens when the watchdog expires?
Should the watchdog be refreshed exactly at the timeout?
Why can the actual watchdog timeout differ from my calculation?
What is a window watchdog?
Can this calculator find the best prescaler?
Does this calculator replace the MCU reference manual?
Calculate Watchdog Timeout and Reload Settings
Convert watchdog oscillator frequency, prescaler and reload values into timeout timing, or find the closest hardware settings for a target MCU watchdog interval.