Chapter 10 Window Watchdog Experiment
10.1 Experimental Purpose This chapter learns the use of another watchdog of STM32 - the window watchdog. For the data sheet, please refer to Chapter 19. 10.2 Experimental Introduction The window watchdog (WWDG) is usually used to monitor software faults caused by external interference or unforeseen logic conditions that cause the application to deviate from the normal operating sequence. Unless the value of the down counter is refreshed before the T6 bit (the sixth bit of WWDG->CR) becomes 0, the watchdog circuit will generate an MCU reset when the preset time period is reached. If the 7-bit down counter value (in the control register) is refreshed before the down counter reaches the window configuration register (WWDG->CFR) value, an MCU reset will also be generated. This means that the down counter needs to be refreshed in a limited time window, as shown in the following figure:
Figure 10.2.1
The window watchdog will trigger a reset under two conditions: When the down counter value is less than 0x40, a reset is generated. When the down counter value is greater than the window value, the counter is reloaded, which generates a reset. So to avoid a reset, the down counter must be reloaded when its value is less than the window register value and greater than 0x3F. Because the window watchdog has a WEI interrupt, when it is enabled, this interrupt is generated when the down counter reaches 0x40. The corresponding interrupt service routine (ISR) can be used to load the counter to prevent the WWDG from resetting. 10.3 Circuit Design Here we use the button box LED circuit in the previous section to verify the monitoring reset function of the window watchdog. 10.4 Software Design Open the experiment 7 window watchdog experiment project in the CD directory 3. Program source code -> 1. Basic experiment ->, open the wwdg.c file under the BSP in the left directory tree, this is the driver file of the window watchdog, the project directory is shown in the figure below:
Figure 10.4.1
Open the wwdg.c file, the code is as follows:
Open the main.c file, the code is as follows:
10.5 Download verification Use a MINI USB cable to connect the computer and the development board through the USB port of CN3, flip the power switch to power on the development board, the D3 power indicator lights up, connect the JLINK/ST-LINK download debugger, open the "Experiment 7 Window Watchdog Experiment" project code, compile and download, the D4 and D5 indicators flash slowly (caused by the reset of the window watchdog WWDG), press the KEY1 button without releasing it, and the D4 and D5 indicators flash quickly (no reset).
This content is originally created by EEWORLD forum user hejecu. If you need to reprint or use it for commercial purposes, you must obtain the author's consent and indicate the source