Watchdog Timeout Calculator
Timeout from prescaler and reload — or the registers for a target timeout.
How the timeout is set
An independent watchdog counts a prescaled clock down from a reload value; if firmware doesn't refresh ("kick") it in time, the counter reaches zero and resets the MCU. The timeout is simply:
On an STM32 the watchdog runs from the low-speed RC oscillator (LSI, ~32 kHz) — which is cheap and always-on but only ±few-percent accurate, so leave margin. The prescaler picks the tick period and the reload (12-bit, 0–4095 on IWDG) sets how many ticks. For a 1 s timeout at 32 kHz with /32 prescaler, RL = 1 s × 32000 / 32 − 1 = 999.
Two rules: kick the dog from your main loop or a low-priority task, never a timer interrupt — an ISR can keep firing while the application has hung, defeating the whole point. And set the timeout comfortably longer than your worst-case loop time, but short enough that a hung product recovers quickly.