cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 : IWDG wake up device in shutdown mode ?

SimonF
Senior

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 !

20 REPLIES 20

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.

For example : https://github.com/STMicroelectronics/STM32CubeF7/blob/c7c5ec99c7482ea8bcdbf0a869c930af4547088f/Projects/STM32756G_EVAL/Examples/FLASH/FLASH_WriteProtection/Src/main.c#L133