Skip to main content
Visitor II
March 3, 2025
Question

MCU not entering into HAL_PWREx_EnterSHUTDOWNMode - black project

  • March 3, 2025
  • 1 reply
  • 524 views

Hello everyone!

Hardware MCU is STM32WB5MMGH

I'm trying to set the MCU in shutdown mode in a complex project, but failing. And with "failing" i mean the code still execute even after the shutdown command run. So the MCU it's not entering shutdown mode.

I've translated the single feature to a new blank project, with just the necessary code for the shutdown feature. And this is the int main :

 

 

int main(void)
{

 /* USER CODE BEGIN 1 */

 /* USER CODE END 1 */

 /* MCU Configuration--------------------------------------------------------*/

 /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
 HAL_Init();

 /* USER CODE BEGIN Init */

 /* USER CODE END Init */

 /* Configure the system clock */
 SystemClock_Config();

 /* Configure the peripherals common clocks */
 PeriphCommonClock_Config();

 /* USER CODE BEGIN SysInit */

 /* USER CODE END SysInit */

 /* Initialize all configured peripherals */
 MX_GPIO_Init();
 MX_RTC_Init();
 /* USER CODE BEGIN 2 */
 HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WUF1);
 HAL_PWREx_EnterSHUTDOWNMode();
 /* USER CODE END 2 */

 /* Infinite loop */
 /* USER CODE BEGIN WHILE */
 while (1)
 {
	HAL_Delay(250);
 /* USER CODE END WHILE */

 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}

 

 

No radios (Core2), nor IWDG at all.

The HAL_PWREx_EnterSHUTDOWNMode also suggest that something is not working, because after the command call, it goes istantly on the CLEAR_BIT line.

 

void HAL_PWREx_EnterSHUTDOWNMode(void)
{
 /* Set Shutdown mode */
 MODIFY_REG(PWR->CR1, PWR_CR1_LPMS, PWR_LOWPOWERMODE_SHUTDOWN);

 /* Set SLEEPDEEP bit of Cortex System Control Register */
 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));

 /* This option is used to ensure that store operations are completed */
#if defined (__CC_ARM)
 __force_stores();
#endif /* __CC_ARM */

 /* Request Wait For Interrupt */
 __WFI();

 /* Following code is executed after wake up if system didn't go to SHUTDOWN
 * or STANDBY mode according to power policy */

 /* Reset SLEEPDEEP bit of Cortex System Control Register */
 CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
}

 

 

Anyone else experienced the same problem ?

1 reply

STTwo-32
Technical Moderator
April 3, 2025

Hello @Balza84 

Could you please try to enter shutdown mode following this sequence:

/* Clear all related wakeup flags */
 __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
	
 if( (LL_PWR_IsActiveFlag_C1SB() == 0)
 || (LL_PWR_IsActiveFlag_C2SB() == 0)
 )
 {
 /* Set the lowest low-power mode for CPU2: shutdown mode */
 LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
 }
	
 /* USER CODE END SysInit */
 
 /* Initialize all configured peripherals */
 
 /* USER CODE BEGIN 2 */
 HAL_SuspendTick();
 HAL_PWREx_EnterSHUTDOWNMode();

Best Regards.

STTwo-32