Independent Watchdog (IWDG)

The tutorial combines LED and KEY to demonstrate the timeout reset function of the independent watchdog (IWDG).

Hardware connection

image-20240825210119907

PeripheralsDevelopment boardDescription
LEDPB3The anode of the LED is connected to the development board PB3, and the cathode is connected to the development board GND
KEY1PA8One end of the KEY is connected to the PA8 pin, and the other end is connected to GND

Control principle

By using a button to reset the count value of the independent watchdog (IWDG), the dog feeding function is realized and the LED is lit.

The STM32F103ZET6 has two built-in watchdogs (independent watchdog and window watchdog), which are mainly used for system fault detection and recovery.

WatchdogFunction
Independent WatchdogUsed to detect whether the system is running normally
Window WatchdogUsed to detect system failure

The independent watchdog (IWDG) is driven by a dedicated low-speed clock (LSI), and it is still effective even if the main clock fails;

When the system does not feed the dog (reset the count value) within a certain period of time, the independent watchdog will trigger a reset operation to restart the system.

image-20231030220806595

PrescalerPR[2:0]Minimum time (ms): RL[11:0]=0x000Maximum time (ms): RL[11:0]=0xFFF
/400.1409.6
/810.2819.2
/1620.41638.4
/3430.83276.8
/6441.66553.6
/12853.213107.2
/2566 or 76.426214.4
TTimeout(s)=42PRReloadLSI=256156400001s

Software Configuration

Software Code

Configure the timeout reset function of the independent watchdog (IWDG), without configuring specific pins.

Control Function

The tutorial only briefly introduces the code, and you can open the project source code for details.

IWDG_Start

Experimental phenomenon

The IWDG.hex file generated by the project compilation is located in the OBJ folder of the IWDG project. Find the IWDG.hex file corresponding to the project and use the FlyMcu software to download the program into the development board.

After the program is downloaded successfully: press KEY1 to feed the dog, the LED lights up; if you do not press KEY, the LED goes out, and the serial port keeps printing start!