73. System window watchdog (WWDG)
73.1 Introduction
The system window watchdog (WWDG) is used to detect the occurrence of a software fault, usually generated by external interference or by unforeseen logical conditions, which causes the application program to abandon its normal sequence.
The watchdog circuit generates a reset on expiry of a programmed time period, unless the program refreshes the contents of the down-counter before the T6 bit is cleared. A reset is also generated if the 7-bit down-counter value (in the control register) is refreshed before the down-counter reaches the window register value. This implies that the counter must be refreshed in a limited window.
The WWDG clock is prescaled from the APB clock and has a configurable time window that can be programmed to detect abnormally late or early application behavior.
The WWDG is best suited for applications requiring the watchdog to react within an accurate timing window.
73.2 WWDG main features
- • Programmable free-running down-counter
- • Conditional reset
- – Reset (if watchdog activated) when the down-counter value becomes lower than 0x40
- – Reset (if watchdog activated) if the down-counter is reloaded outside the window (see Figure 855)
- • Early wake-up interrupt (EWI): triggered (if enabled and the watchdog activated) when the down-counter is equal to 0x40
73.3 WWDG implementation
Table 705. STM32MP23/25xx WWDG features(1) (2)
| WWDG mode / feature | WWDG1 | WWDG2 |
|---|---|---|
| Window function | X | X |
| Early wake-up interrupt generation | X(3) | X(4) |
| System reset generation | _(5) | _(6) |
| Capability to work in system Stop | - | X |
| Capability to work in system Standby | - | X(7) |
| Capability to be frozen when the microcontroller enters in Debug mode | X | X |
| Option bytes to control the hardware mode | - | - |
1. “X” = supported, “-” = not supported
2. Refer to Watchdogs overview for more details.
3. WWDG1 can generate interrupts for CPU2.
- 4. WWDG2 can generate interrupts for CPU3.
- 5. The wwdg_out_rst signal of WWDG1 generates an interrupt for CPU1. No reset is generated.
- 6. The wwdg_out_rst signal of WWDG2 generates an interrupt for CPU1 and CPU2. No reset is generated.
- 7. WWDG2 can work in Standby1 mode. The activation of wwdg_out_rst signal can wake-up CPU1 and CPU2 from Standby1 mode. WWDG2 cannot work in Standby2 mode.
73.4 WWDG functional description
If the watchdog is activated (the WDGA bit is set in the WWDG_CR register), and when the 7-bit down-counter (T[6:0] bits) is decremented from 0x40 to 0x3F (T6 becomes cleared), it initiates a reset. If the software reloads the counter while the counter is greater than the value stored in the window register, then a reset is generated.
The application program must write in the WWDG_CR register at regular intervals during normal operation to prevent a reset. This operation can take place only when the counter value is lower than or equal to the window register value, and higher than 0x3F. The value to be stored in the WWDG_CR register must be between 0xFF and 0xC0.
Refer to Figure 854 and to Section 73.4.2: WWDG internal signals for the WWDG block diagram.
73.4.1 WWDG block diagram
Figure 854. Watchdog block diagram

The diagram illustrates the internal structure of the WWDG. An external pclk input is divided by 4096 and then by \(2^{WDGTB}\) to drive a 7-bit down-counter (CNT). The counter output T[6:0] is fed into a CMP (Comparator) block, which outputs CMP = 1 when T[6:0] > W[6:0]. The WWDG_CR register provides a preload value to the counter and a readback path. The WWDG_CFR register provides the window value W[6:0] to the CMP. The WWDG_SR register is also present. The WDGA (Window Debug Activation) bit from WWDG_CR enables the watchdog. The CMP output and WDGA are combined with T6 (the most significant bit of the counter) through logic gates to generate the wwdg_out_rst signal. Additionally, the counter output T[6:0] is compared to 0x40 to generate cnt_out, which, along with EWI and EWIF, feeds into a Logic block to produce the wwdg_it interrupt signal. The entire block is connected to the APB bus via a Register interface.
MS47214V2
73.4.2 WWDG internal signals
Table 706 gives the list of WWDG internal signals.
Table 706. WWDG internal input/output signals
| Signal name | Signal type | Description |
|---|---|---|
| pclk | Digital input | APB bus clock |
Table 706. WWDG internal input/output signals (continued)
| Signal name | Signal type | Description |
|---|---|---|
| wwdg_out_rst | Digital output | WWDG reset signal output |
| wwdg_it | Digital output | WWDG early interrupt output |
73.4.3 Enabling the watchdog
The watchdog is always disabled after a reset. It is enabled by setting the WDGA bit in the WWDG_CR register, then it cannot be disabled again except by a reset.
73.4.4 Controlling the down-counter
This down-counter is free-running, counting down even if the watchdog is disabled. When the watchdog is enabled, the T6 bit must be set to prevent generating an immediate reset.
The T[5:0] bits contain the number of increments that represent the time delay before the watchdog produces a reset. The timing varies between a minimum and a maximum value, due to the unknown status of the prescaler when writing to the WWDG_CR register (see Figure 855). The WWDG configuration register (WWDG_CFR) contains the high limit of the window: to prevent a reset, the down-counter must be reloaded when its value is lower than or equal to the window register value, and greater than 0x3F. Figure 855 describes the window watchdog process.
Note: The T6 bit can be used to generate a software reset (the WDGA bit is set and the T6 bit is cleared).
73.4.5 How to program the watchdog timeout
Use the formula in Figure 855 to calculate the WWDG timeout.
Warning: When writing to the WWDG_CR register, always write 1 in the T6 bit to avoid generating an immediate reset.
Figure 855. Window watchdog timing diagram
![Figure 855. Window watchdog timing diagram. The diagram shows the CNT down-counter decreasing over time, with a window defined by T[6:0] and W[6:0]. The window is divided into 'Refresh not allowed' and 'Refresh allowed' regions. The WWDG counter (W[6:0]) is shown resetting to 0x41 when the CNT reaches 0x41. The WWDG counter then counts down to 0x3F, at which point the WWDG_RST signal is asserted. The T6 bit is also shown. A callout shows the WWDG counter values 0x41, 0x40, and 0x3F, with a time interval T_pclk x 4096 x 2^WDDGTB[2:0] between 0x41 and 0x3F. The EWIF signal is shown going low when the WWDG counter reaches 0x3F.](/RM0457-STM32MP23-25/c10962af43d09ed1cd89844a59167556_img.jpg)
The diagram illustrates the timing of the Window Watchdog (WWDG). The CNT down-counter starts at T[6:0] and counts down to 0x3F. The WWDG counter (W[6:0]) is loaded with 0x41 when the CNT reaches 0x41. The WWDG counter then counts down to 0x3F, at which point the WWDG_RST signal is asserted. The T6 bit is also shown. A callout shows the WWDG counter values 0x41, 0x40, and 0x3F, with a time interval \(T_{pclk} \times 4096 \times 2^{WDDGTB[2:0]}\) between 0x41 and 0x3F. The EWIF signal is shown going low when the WWDG counter reaches 0x3F.
The formula to calculate the timeout value is given by:
where:
- • \(t_{WWDG}\): WWDG timeout
- • \(t_{PCLK}\): APB clock period measured in ms
- • 4096: value corresponding to internal divider
As an example, if APB frequency is 48 MHz, WDDGTB[2:0] is set to 3, and T[5:0] is set to 63:
Refer to the datasheet for the minimum and maximum values of \(t_{WWDG}\).
73.4.6 Debug mode
When the CPU enters debug mode, WWDG counter either continues to work normally or stops, depending on debug settings. For more details refer to Section 73.3: WWDG implementation and to Section 97: Debug support (DBG).
73.5 WWDG interrupts
The early wake-up interrupt (EWI) can be used if specific safety operations or data logging must be performed before the reset is generated. To enable the early wake-up interrupt, the application must:
- • Write EWIF bit of WWDG_SR register to 0, to clear unwanted pending interrupt
- • Write EWI bit of WWDG_CFR register to 1, to enable interrupt
When the down-counter reaches the value 0x40, a watchdog interrupt is generated, and the corresponding interrupt service routine (ISR) can be used to trigger specific actions (such as communications or data logging), before resetting the device.
In some applications, the EWI interrupt can be used to manage a software system check and/or system recovery/graceful degradation, without generating a WWDG reset. In this case the corresponding ISR must reload the WWDG counter to avoid the WWDG reset, then trigger the required actions.
The watchdog interrupt is cleared by writing 0 to the EWIF bit in the WWDG_SR register.
Note: When the watchdog interrupt cannot be served (for example due to a system lock in a higher priority task), the WWDG reset is eventually generated.
73.6 WWDG registers
Refer to Section 1.2: List of abbreviations for registers for a list of abbreviations used in register descriptions.
The peripheral registers can be accessed by halfwords (16-bit) or words (32-bit).
73.6.1 WWDG control register (WWDG_CR)
Address offset: 0x000
Reset value: 0x0000 007F
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | WDGA | T[6:0] | ||||||
| rs | rw | rw | rw | rw | rw | rw | rw | ||||||||
Bits 31:8 Reserved, must be kept at reset value.
Bit 7 WDGA: Activation bit
This bit is set by software and only cleared by hardware after a reset. When WDGA = 1, the watchdog can generate a reset.
0: Watchdog disabled
1: Watchdog enabled
Bits 6:0 T[6:0]: 7-bit counter (MSB to LSB)
These bits contain the value of the watchdog counter, decremented every \((4096 \times 2^{\text{WDGTB}[2:0]})\) PCLK cycles. A reset is produced when it is decremented from 0x40 to 0x3F (T6 becomes cleared).
73.6.2 WWDG configuration register (WWDG_CFR)
Address offset: 0x004
Reset value: 0x0000 007F
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | WDGTB[2:0] | Res. | EWI | Res. | Res. | W[6:0] | ||||||||
| rw | rw | rw | rs | rw | rw | rw | rw | rw | rw | rw | |||||
Bits 31:14 Reserved, must be kept at reset value.
Bits 13:11 WDGTB[2:0]: Timer base
The timebase of the prescaler can be modified as follows:
- 000: CK counter clock (PCLK div 4096) div 1
- 001: CK counter clock (PCLK div 4096) div 2
- 010: CK counter clock (PCLK div 4096) div 4
- 011: CK counter clock (PCLK div 4096) div 8
- 100: CK counter clock (PCLK div 4096) div 16
- 101: CK counter clock (PCLK div 4096) div 32
- 110: CK counter clock (PCLK div 4096) div 64
- 111: CK counter clock (PCLK div 4096) div 128
Bit 10 Reserved, must be kept at reset value.
Bit 9 EWI: Early wake-up interrupt enable
Set by software and cleared by hardware after a reset. When set, an interrupt occurs whenever the counter reaches the value 0x40.
Bits 8:7 Reserved, must be kept at reset value.
Bits 6:0 W[6:0]: 7-bit window value
These bits contain the window value to be compared with the down-counter.
73.6.3 WWDG status register (WWDG_SR)
Address offset: 0x008
Reset value: 0x0000 0000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | EWIF |
| rc_w0 |
Bits 31:1 Reserved, must be kept at reset value.
Bit 0 EWIF: Early wake-up interrupt flag
This bit is set by hardware when the counter has reached the value 0x40. It must be cleared by software by writing 0. Writing 1 has no effect. This bit is also set if the interrupt is not enabled.
73.6.4 WWDG hardware configuration register (WWDG_HWCFGR)
Address offset: 0x3F0
Reset value: 0x0000 1000
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| PREDIV[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:16 Reserved, must be kept at reset value.
Bits 15:0 PREDIV[15:0]: The watchdog clock is prescaled by 4096 (PREDIV[15:0]).
73.6.5 WWDG version register (WWDG_VERR)
Address offset: 0x3F4
Reset value: 0x0000 0021
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| Res. | Res. | Res. | Res. | Res. | Res. | Res. | Res. | MAJREV[3:0] | MINREV[3:0] | ||||||
| r | r | r | r | r | r | r | r | ||||||||
Bits 31:8 Reserved, must be kept at reset value.
Bits 7:4 MAJREV[3:0]: WWDG major revision
Bits 3:0 MINREV[3:0]: WWDG minor revision
73.6.6 WWDG identification register (WWDG_IPIDR)
Address offset: 0x3F8
Reset value: 0x0012 0051
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| ID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| ID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 ID[31:0]: WWDG peripheral identifier
73.6.7 WWDG size identification register (WWDG_SIDR)
Address offset: 0x3FC
Reset value: 0xA3C5 DD01
| 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 |
| SID[31:16] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
| 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
| SID[15:0] | |||||||||||||||
| r | r | r | r | r | r | r | r | r | r | r | r | r | r | r | r |
Bits 31:0 SID[31:0]: The address decoding range is 1 Kbyte
73.6.8 WWDG register map
The following table gives the WWDG register map and reset values.
Table 707. WWDG register map and reset values
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x000 | WWDG_CR | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | WDGA | T[6:0] | |||||||
| Reset value | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||||||||||||||||||||||||
| 0x004 | WWDG_CFR | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | WDGTB [2:0] | Res | EWI | Res | Res | W[6:0] | ||||||||
| Reset value | 0 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | ||||||||||||||||||||||
| 0x008 | WWDG_SR | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | EWIF | ||
| Reset value | 0 | ||||||||||||||||||||||||||||||||
| 0x00C-0x3EC | Reserved | Reserved | |||||||||||||||||||||||||||||||
| 0x3F0 | WWDG_HWC FGR | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | PREDIV[15:0] | ||||||||||||||||
| Reset value | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | ||||||||||||||||
| 0x3F4 | WWDG_VERR | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | Res | MAJREV [3:0] | MINREV [3:0] | |||||||
| Reset value | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | ||||||||||||||||||||||||
Table 707. WWDG register map and reset values (continued)
| Offset | Register name | 31 | 30 | 29 | 28 | 27 | 26 | 25 | 24 | 23 | 22 | 21 | 20 | 19 | 18 | 17 | 16 | 15 | 14 | 13 | 12 | 11 | 10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0x3F8 | WWDG_IPIDR | ID[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 0 | 1 | |
| 0x3FC | WWDG_SIDR | SID[31:0] | |||||||||||||||||||||||||||||||
| Reset value | 1 | 0 | 1 | 0 | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 1 | 1 | 0 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | |
Refer to Section 2.4 on page 228 for the register boundary addresses.
