Im trying to understand how Independent watchdog really works and i wrote a piece of code that runs on STM32F411VE Eval board. I believe i have configured the Watchdog Timer correctly according to Reference manual.
The Independent WDOG Timer is configured with Internal LSI with a frequency of 32KHz and a pre-scaler of 64. The counter is set to 256. So if the Reload counter is not loaded within 0.5 seconds, the MCU should be reset. Is my understanding wrong?
What i dont understand is, the watchdog reset comes way too late than expected (5-6 seconds) if the counter value is not reloaded. I fail to understand why. Here's my Code.
//Initialise Independent Watchdog
void init_independent_wdog(void){
IWDG_WriteAccessCmd(IWDG_WriteAccess_Enable);
if(!IS_BIT_SET(IWDG->SR,0)){
IWDG_SetPrescaler(IWDG_Prescaler_64);
}
//Set counter value to 256
if(!IS_BIT_SET(IWDG->SR,1)){
IWDG_SetReload(0x0100);
}
IWDG_Enable();
}
int main(void)
{
SystemInit();
SysTick_Init();
//Initialize On-board LED GPIOs
init_led_gpios();
//Initialize On-board USART
init_usart6_gpio();
init_usart6_comm_module();
//Initialize External Interrupt Button
init_exti_struct();
enable_exti_irq();
//Initialize Independent WDOG
init_independent_wdog();
USART_TX_string("Hello1\n\r");
while (1);
}
//Interrupt triggered when User Button at PA0 is pressed
void EXTI0_IRQHandler(void)
{
if (EXTI_GetITStatus(EXTI_Line0) != RESET)
{
GPIO_ToggleBits(GPIOD, GPIO_Pin_15);
IWDG_ReloadCounter();
EXTI_ClearITPendingBit(EXTI_Line0);
}
}