Window Watchdog (WWDG)

The tutorial combines LED, buzzer, and KEY to demonstrate the hardware fault detection function of the window watchdog (WWDG).

Hardware connection

image-20240825210433047

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
Buzzer (active buzzer)PA11 

Control principle

The STM32F103RCT6 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 failures

The window watchdog (WWDG) is driven by the clock obtained by dividing the APB1 clock. It detects abnormal late or early operations of the application by configuring the time window.

Window WatchdogStatus
Feed the watchdog when the count value > window upper limitReset
Feed the watchdog when the window upper limit > count value > window lower limitDo not reset
Count value < window lower limitReset

image-20240903164619741

image-20240903164635243

WDGBMinimum timeoutMaximum timeout
0113us7.28ms
1227us14.56ms
TWWDG(ms)=TPCLK140962WDGTB(T[5:0]+1)

TWWDG: WWDG timeout time

TPCLK1: APB1 time interval in ms

Example: Counter minus 1 time (PCLK1=36MHz, frequency division number is 8)

TWWDG(ms)=TPCLK140962WDGTB(T[5:0]+1)=136000409623(1)=0.910ms

Software Configuration

Software Code

Configure the Window Watchdog (WWDG) hardware fault detection function, no need to configure specific pins.

Control Function

The tutorial only briefly introduces the code, you can open the project source code to read it.

IWDG_Start

Experimental phenomenon

The WWDG.hex file generated by the project compilation is located in the OBJ folder of the WWDG project. Find the WWDG.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: Pressing KEY1 will trigger the dog not to be fed (equivalent to reset: LED turns off, buzzer beeps, serial port prints WWDG start!), if KEY1 is not pressed, the dog will be fed continuously (LED is always on)

image-20240827180158601