Explanation
There’s no way to enable watchdogs manually in software as they are always enabled. However, there
are configuration bits to select if the IWDG and the WWDG are enabled in software or hardware. They
only come in effect when configured. This is cool.
For WWDG, we just need to set the value of the down counter and the window register value only.
void WWDG_setup(void)
{
WWDG_Init(0x7F, 0x60);
}
We need to monitor the WWDG in order to reload it when it is the right time window.
while(TRUE)
{
if((GPIO_ReadInputPin(GPIOB, GPIO_PIN_7) == FALSE) || ((WWDG_GetCounter() > 0x60) && (WWDG_GetCounter() <
0x7F)))
{
WWDG_SetCounter(0x7F);
}
GPIO_WriteReverse(GPIOD, GPIO_PIN_0);
delay_ms(20);
};
Remember too early of too late will reset the micro.
Demo
Video link: https://www.youtube.com/watch?v=a_JWHJCh_-o