STM32 Watchdogs
From the point of view of embedded systems, a watchdog is a device which monitors a system and is able to restart the system if or when something goes wrong. STM32 MCUs are equipped with two watchdogs: the Independent Watchdog (IWDG) and a Window Watchdog (WWDG). These watchdogs will be described in the following sections.
Independent Watchdog (IWDG)
The IWDG is, as the name implies, an independent device which watches over the MCU. It can be illustrated like this:
In the STM32, the IWDG is built-into the MCU itself, but it is still a completely independent device. So much in fact that it is not possible to read the counter value during run-time.
Calculating Time
The IWDG is clocked from the internal (or external) low speed timer. By default, without an external crystal, this is running at 32000 kHz. The formula to calculate the reset time is like this:
The counter is a 12-bit value, so possible to configure from 1 - 4096 and the prescaler can be configured to: 4, 8, 16, 32, 64, 128 or 256.
The calculation therefore is quite simple. If we want, for example, a reset time of 1.5 seconds, we can calculate the counter value like this:
C = 1.5 * 32000 / 16 = 3000
Notice that by default the low speed oscillator is a simple built-in RC oscillator which is far less precise than a crystal would be. It is therefore important to leave some room for drive. If we set the reset time at 1.5 seconds, we should probably kick the watchdog once every second or so.
Window Watchdog (WWDG)
To be added
Miscellaneous Links
To be added