Skip to main content
Associate III
June 16, 2025
Solved

SHUTDOWN mode WUP Pin works but no WUF is set at wakeup

  • June 16, 2025
  • 2 replies
  • 434 views

I've a custom board that going to SHUTDOWN OFF mode 

I'm using the LPM lib and it use PA0 as WAKEUP PIN 

it wakes up on a High level signal 

void PWR_EnterOffMode(void)
{
/* USER CODE BEGIN PWR_EnterOffMode_1 */

	// refer to the following link for more details on how to go to Off Mode
	// https://community.st.com/t5/stm32-mcus-embedded-software/how-to-enter-standby-or-shutdown-mode-on-stm32/m-p/145849
	// https://community.st.com/t5/stm32-mcus-wireless/stm32wb55-shutdown-mode-standby-mode-wake-up-with-syswkup-pin/m-p/67480#M812

	/* Enable Backup domain write */
	HAL_PWR_EnableBkUpAccess();

	/*Disable RTC */
	CLEAR_BIT(RCC->BDCR, RCC_BDCR_RTCEN);

	/* Disable LSE */
	CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON);


	/* Disabel Backup domain write */
	HAL_PWR_DisableBkUpAccess();
	/* See : https://community.st.com/t5/stm32-mcus-embedded-software/how-to-enter-standby-or-shutdown-mode-on-stm32/m-p/145849 */

/* USER CODE END PWR_EnterOffMode_1 */
 /**
 * The systick should be disabled for the same reason than when the device enters stop mode because
 * at this time, the device may enter either OffMode or StopMode.
 */
 HAL_SuspendTick();

 EnterLowPower();

 /************************************************************************************
 * ENTER OFF MODE
 ***********************************************************************************/
 /*
 * There is no risk to clear all the WUF here because in the current implementation, this API is called
 * in critical section. If an interrupt occurs while in that critical section before that point,
 * the flag is set and will be cleared here but the system will not enter Off Mode
 * because an interrupt is pending in the NVIC. The ISR will be executed when moving out
 * of this critical section
 */
 LL_PWR_ClearFlag_WU();

 LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);

 LL_LPM_EnableDeepSleep(); /**< Set SLEEPDEEP bit of Cortex System Control Register */

 /* Disable all used wakeup sources */
 HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1_LOW);

 /* Clear all wake up Flag */
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);

 /* Enable WakeUp Pin PWR_WAKEUP_PIN1 connected to PA0 */
 HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH);

 /* Clear all related wakeup flags*/
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WUF1);

 // Disable debug, trace and IWDG in low-power modes
 DBGMCU->CR = 0; 
 /**
 * This option is used to ensure that store operations are completed
 */
#if defined (__CC_ARM) || defined (__ARMCC_VERSION)
 __force_stores(); // comment : looks that CC_ARM or ARMCC_VERSION are not define and therefore not build 
#endif
 for(;;){
	__DSB();
	__WFI();
 }
}

it works ok for waking the cpu but I have no WF1 set in PWR->SR1 register at wakeup 

so I'm not able to differenciate a WKUP of a BORRST

I've try different relative orders of actions and nothing seems to act on WUFx

any idea would be greatly appreciated 

 

 

Best answer by STTwo-32

Hello @oga 

The WUF1 flag in the `PWR->SR1` register is not set after waking up from Shutdown mode because, as stated in the RM0473, A power-on reset occurs when exiting from Shutdown mode. All registers (except for the ones in the Backup domain) are reset after wake-up from Shutdown. So, the WUF1 is reset after exiting the Shutdown mode.

Best Regards.

STTwo-32

2 replies

STTwo-32
STTwo-32Best answer
Technical Moderator
June 16, 2025

Hello @oga 

The WUF1 flag in the `PWR->SR1` register is not set after waking up from Shutdown mode because, as stated in the RM0473, A power-on reset occurs when exiting from Shutdown mode. All registers (except for the ones in the Backup domain) are reset after wake-up from Shutdown. So, the WUF1 is reset after exiting the Shutdown mode.

Best Regards.

STTwo-32

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ogaAuthor
Associate III
June 18, 2025

is there a way to differentiate if Ive been woke up by a real POR or by a POR induced by a WKUP ?? 

STTwo-32
Technical Moderator
June 19, 2025

When exiting Shutdown mode, a Brown-out reset is generated, resetting all registers except
those in the Backup domain. So, unfortunately, you can't recognize the source of the Wake-up.

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.