2025-03-18 12:49 AM
Hi for everyone,
I try to implement window watchdog to my system. I got reset every single time during enabling watchdog in HAL_WWDG_Init() function and exactly WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter)); here.
These are my watchdog configuration
hwwdg.Instance = WWDG;
hwwdg.Init.Prescaler = WWDG_PRESCALER_8;
hwwdg.Init.Window = 64;
hwwdg.Init.Counter = 127;
hwwdg.Init.EWIMode = WWDG_EWI_DISABLE;
I want to start watchdog and feed periodically but now, I just got reset and even dont even initialize successfully. It is default init function of library as you know. What should I do to successfully initialize Watchdog, feed it periodically, and ensure it runs properly?
I will be grateful for your help.
2025-03-18 5:22 AM
Here is an example WWDG usage. I'd recommend getting that up and running.
Unlike the IWDG, the WWDG requires you to refresh it within a particular window. If you refresh outside of that window, it will reset. In your program, how do you ensure you're refreshing within that window?
The code presented looks fine.
2025-03-18 5:36 AM
Thanks for reply.
I tried the example already but I am facing a problem in init function
HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
{
/* Check the WWDG handle allocation */
if (hwwdg == NULL)
{
return HAL_ERROR;
}
/* Check the parameters */
assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler));
assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window));
assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter));
assert_param(IS_WWDG_EWI_MODE(hwwdg->Init.EWIMode));
#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
/* Reset Callback pointers */
if (hwwdg->EwiCallback == NULL)
{
hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
}
if (hwwdg->MspInitCallback == NULL)
{
hwwdg->MspInitCallback = HAL_WWDG_MspInit;
}
/* Init the low level hardware */
hwwdg->MspInitCallback(hwwdg);
#else
/* Init the low level hardware */
HAL_WWDG_MspInit(hwwdg);
#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
/* Set WWDG Counter */
WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter));
/* Set WWDG Prescaler and Window */
WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window));
/* Return function status */
return HAL_OK;
}
WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter)); line reset the system.
I created a timer to periodically refresh the watchdog every 20 seconds, but the main problem is I cannot skip wwdg_init successfully. I get reset just after enabling watchdog. My APB1 peripheral clock is 54 MHz. (maximum speed)
hwwdg.Instance = WWDG; hwwdg.Init.Prescaler = WWDG_PRESCALER_8; hwwdg.Init.Window = 64; hwwdg.Init.Counter = 127; hwwdg.Init.EWIMode = WWDG_EWI_DISABLE;
and there is my watchdog configuration. What can I do now in this situation? Waiting for your answers.
2025-03-19 4:01 AM
can you help me about the problem I am facing? @TDK
2025-03-19 4:48 AM
Did you get the example up and running?
> I created a timer to periodically refresh the watchdog every 20 seconds
Seems like a long time. How quickly does the watchdog need refreshed?
How do you know it's resetting immediately after that line as opposed to, say, 5ms after due to no refreshing the counter?