Showing results for 
Search instead for 
Did you mean: 

STM32L433 IWDG wakes up from SHUTDOWN Mode

Jonathan Frech
Associate II

In my use-case i want to have a watch-dog active when the device is in use to prevent software stucks or accidental ending in endless loops. Therefore i have configured the IWDG like this:

void hw_IWDG_Init(void){
	IwdgHandle.Instance = IWDG;
	IwdgHandle.Init.Prescaler = IWDG_PRESCALER_256;
	IwdgHandle.Init.Reload = 0x0BB8;
	IwdgHandle.Init.Window = IWDG_WINDOW_DISABLE;
	if(HAL_IWDG_Init(&IwdgHandle) != HAL_OK)
		/* Initialization Error */
		_Error_Handler(__FILE__, __LINE__);

This should give me a IWDG Reset between 22.2 and 26s, depending on LSI accuracy according to datasheet (29.5 - 34kHz).

In normal operation, this works fine, but when the device is shut down, the watchdog should stop operating. According to datasheet, the watchdog is NOT ACTIVE in SHUTDOWN

Measuring with OTII, i get a average of 1uA current, which confirms that the device is actually entering SHUTDOWN. (Datasheet says 313nA at 3.6V, but there are other ic's on the board and measuring accuracy).

I enter Shutdown as following:

	/* Disable used wakeup source: PWR_WAKEUP_PIN1 */
	  /* Clear all related wakeup flags */
	  /* Enable wakeup pin WKUP1 */
	  if(pol = WUPOL_HIGH){
	  /* Set RTC back-up register RTC_BKP31R to indicate
	       later on that system has entered shutdown mode  */
	  //WRITE_REG( RTC->BKP31R, 0x1 );
	  /* Enter the Shutdown mode */

I also modiefied HAL_PWREx_EnterSHUTDOWNMode as following:

  /* Set Shutdown mode */
  /* Set SLEEPDEEP bit of Cortex System Control Register */
/* This option is used to ensure that store operations are completed */
#if defined ( __CC_ARM)
  PWR->SR1 &= ~PWR_SR1_WUF;				//MODIFYED!!
  __SEV();								//MODIFYED!!
  __WFE();								//MODIFYED!!
  /* Request Wait For Interrupt */

But yet, my device wakes up after 23 seconds.

Is there anyway i can further debug this?

What could be causing this malfunction?

Jack Peacock_2
Senior III

Look at the IWDG_STDBY flag in the option bytes. This halts IWDG in STANDBY and SHUTDOWN mode.

Jack Peacock

I forgot to mention that i use Atollic TrueStudio. As far as i know, this IDE does not support Option bytes at all, or am i wrong? Usually Option Bytes are programmed via ST-Link or CubeProgrammer when using .hex file for delivery and the link chain from there

I am not much into the low-power modes. I personally would double-check by reading back registers at every step taken towards the chosen low-power mode.


Chief II

Few days ago I also stumbled on this on a STM32L433 and found this topic:

It seems that the OP also have found it and tried the "solution" provided by Imen. To me it seemed highly suspicious from the first look and it proved to be what it seems to be - absolutely unrelated to the problem and not fixing anything. But a bit of thinking and guessing and I found it. IWDG seems to be powered from the same power line the debug interface is powered and should be disabled before entering shutdown mode. Take a note that it must be disabled anyway, otherwise debug interface will consume current even in shutdown mode and those bits are not reset by system reset.

#ifdef NDEBUG
	DBGMCU->CR = 0; // Disable debug, trace and IWDG

ST's employees are not running into this issue because ST-LINK and their test code doesn't set these bits, but J-Link, probably other probes and more complex code can set these bits.

Problem reports go back to at least a year 2016. For me it doesn't seem like a hardware bug, but more like an inadequate documentation. @Imen DAHMEN​, @Tomas SIRUCEK​, someone should finally tackle this and update the reference manuals in all related STM32 series. And, as it will probably take a long time, at least inform us here for which series my findings are true.

Documentation doesn't mention shutdown mode at flags in option bytes.

Thank you for this answer! This was able to resolve my issue. As long as the ST-Link is connected, the WD does run in Shutdown (no matter if really debugging or just plugged in). After removing the ST-Link Cable, the Device works correctly!

> Thank you for this answer! This was able to resolve my issue. As long as the ST-Link is connected, the WD does run in Shutdown

> (no matter if really debugging or just plugged in). After removing the ST-Link Cable, the Device works correctly!

And what is the content of DBGMCU_CR?


Is this solution suitable for all MCUs?

I tried it on STM32WB55CE with no success.

Very helpful post, thanks! I can confirm that the option byte IWDG_STDBY (set it in the cubeprogrammer) does affect also SHUTDOWN mode. The IWDG timer kept running in SHUTDOWN mode until I unchecked this option byte.