2020-04-28 07:08 AM
Hi,
I have found a bug in the instructions order in code generated by STM32CubeIDE v1.3.0 for the IWDG (STM32G474) with LL drivers. The code itself pads the watchdog outside the acceptance window as soon as the window is set to a value sufficiently far from the default.
An example code for auto-generated function is:
void MX_IWDG_Init(void)
{
LL_IWDG_Enable(IWDG);
LL_IWDG_EnableWriteAccess(IWDG);
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_4);
LL_IWDG_SetWindow(IWDG, 100);
LL_IWDG_SetReloadCounter(IWDG, 120);
while (LL_IWDG_IsReady(IWDG) != 1)
{
}
LL_IWDG_ReloadCounter(IWDG);
}
Explanation:
Problematic here is what happens starting from the call to "LL_IWDG_SetWindow".
In my case window values of 4095 down to 4089 do work by accident, since the reloading then falls within the window (will depend on system clock). Using any window value smaller than this results in system reset (independent of the programmed reload value)
The correct code that is working for me is (compare also to the recommended init sequence in RM0440 Rev4 attached):
void MX_IWDG_Init(void)
{
LL_IWDG_Enable(IWDG);
LL_IWDG_EnableWriteAccess(IWDG);
LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_4);
LL_IWDG_SetReloadCounter(IWDG, 120);
while (LL_IWDG_IsReady(IWDG) != 1)
{
}
LL_IWDG_SetWindow(IWDG, 100);
}
2020-04-28 08:49 AM
Hello @MScho.1
I will check it and I will raise internally to take into consideration
Thank you for your contribution
Regards,
2020-05-18 03:45 AM
Hi @MScho.1 ,
Issue fixed, the fix will be available for the next CubeMX release.
Best Regards,
Khouloud