2019-11-20 08:00 AM
Hi !
I'm using the stm32l452RE mcu and I use the shutdown mode. I also use the watchdog (IWDG) to reset the system if an error occurs. This IWDG is set to 4s. When I go in shutdown mode, accordly to the docs, IWDG should be off because it is clocked with LSI which is off.
Despite this, the device resets exactly after 4s.
If I change IWDG to 10s, device reset after 10s. That's why I'm sure IWDG continues working even when my device goes in shutdown mode.
The only thing I'm not sure is if I really enter in shutdown. Here below is what I do to enter in shutdown mode :
HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW);
HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1);
/* Clear flag */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUFI);
HAL_PWREx_EnterSHUTDOWNMode();
For the IWDG set up, here is what I do :
void MX_IWDG_Init(void)
{
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_32;
hiwdg.Init.Window = IWDG_WINDOW_DISABLE;
hiwdg.Init.Reload = (32000 * 4095) / (32 * 1000);
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
Error_Handler();
}
}
Have you any idea ?
Thanks for your help !
Solved! Go to Solution.
2022-07-21 11:57 PM
Okay I got it. To be tested but can a be a good solution to the original post I did.
Note for future readers that you cannot just call a simple macro or clean the register. You have to unlock flash and option bytes register.