The window watchdog (WWDG) is used to discover software failures caused by external interfaces or unexpected logical operations. These failures can cause program outages to run correctly. At the end of a program cycle, the watchdog circuit generates an MCU reset signal unless the program returns to normal operating logic before the watchdog circuit is reset. When the counter is reduced to a preset value, a reset signal is also generated. This means that the counter must be confined within a specified window.
"Window watchdog main Features"
1. Programmable down counter 2, Reset Condition: Counter value is less than 0x40 or counter value exceeds the set window. 3, the early wake-up interrupt (EWI) count is equal to 0x40 when the interrupt, that is, equal to 0x40 the resulting interrupt is less than 0x40 reset.
Generate Reset Condition: counter counts to less than 0x40, the counter value is less than the window value set in the configuration register (CFR) to produce a reset signal
The count value of the window counter varies between 0x7f and 0x40. Once the window counter is enabled, it cannot be stopped until reset. Even without the Enable window watchdog, its counter will continue to count, so in order to avoid being reset at the beginning of the count, the counter must be set to a value greater than or equal to 0x40 that is, the T6 bit in the CR must be set to 1 and less than the preset value, and then start WWDG
Regarding the use of Windows watchdog, St's people have done some introductions. I made a mistake at the beginning when I thought I would feed the dog. This is not the case, actually.
The window watchdog is characterized by the inability to feed the dog when the dog is full, or when the dog is hungry
The dog feeds the dog when he is hungry, the dog bites, and when the dog is full, the dog bites; only in a time period, when the Dog man hunger to feed, the dog can work obediently.
The general watchdog is able to feed the dog at any time, whether the dog is full or not.
this time is the counter number in the t[6..0] to 0x40 between, only can feed the dog. Here's the window that can be understood as feeding the dog's window ...
The ST manual also has a clear explanation:
If The watchdog is activated (the WDGA bit was set in the WWDG_CR register) and when the 7-bit downcounter (t[6:0] bits) ro Lls over from 0x40 to 0x3F (T6 becomes cleared), it initiates a reset. If the software reloads the counter while the counter are greater than the value stored in the Windows register, then a Rese T is generated
The WWDG uses the APB1 clock, internally with a divider wdgtb[1..0] and a counter t[6..0]. Prescaler WDGTB is a pair (tpclk1/4096) to get the watchdog clock.
Time-Out calculation formula: TWWDG = TPCLK1X4096X2^WDGTB * (t[5:0]+1)
"Experimental Steps"
1, WWDG turn on the clock
2. Set the Prescaler Value and window value Wwdg_setprescaler ()/wwdg_setwindowvalue () These values are not changed until the MCU Reset is started
3, enable WWDG wwdg_enable ()
4. Feeding the dog or not feeding the dog (Wwdg_setcounter ())
For the first time, we don't feed the dog, and we can see the LEDs flashing constantly. It means the MCU is reset.
int main ()
{
Nvic_config ();
Led_init ();
LeDon (LED1);
Delay_ms (500);
Ledoff (LED1);
Rcc_apb1periphclockcmd (rcc_apb1periph_wwdg,enable);
Wwdg_deinit ();
Wwdg_setprescaler (Wwdg_prescaler_8);
Wwdg_setwindowvalue (0x7F);
Wwdg_enable (0x5f);
while (1)
{
Don't feed the dog, watch the lights flash
}
}
The second time, every once in a while to feed the dog to see the light does not blink
int main ()
{
Nvic_config ();
Led_init ();
LeDon (LED1);
Delay_ms (500);
Ledoff (LED1);
Rcc_apb1periphclockcmd (rcc_apb1periph_wwdg,enable);
Wwdg_deinit ();
Wwdg_setprescaler (Wwdg_prescaler_8);
Wwdg_setwindowvalue (0x7F);
Wwdg_enable (0x5f);
while (1)
{
Feed the dog in the Dog-feeding window
if ((WWDG->CR & 0x7F) = = 0x55)
{
Wwdg_setcounter (0x7f);
}
}
}
Alternatively, you can use interrupts to handle watchdog events. But it seems that St's people do not recommend this.