Skip to main content
LM.2
Associate II
November 5, 2024
Question

STM32WB Sleep mode issues

  • November 5, 2024
  • 1 reply
  • 994 views

Hey, we are developing a product using a STM32WB5MMGHx on a custom PCB and using ThreadX instead of the scheduler + TinyLPM.  

I'm having issues getting the MCU into a suitably low power sleep mode, and I'm seeing odd behaviour where lower current draw is measured in STOP_2 vs SHUTDOWN mode. 

my code for entering SHUTDOWN mode 

 

	DBGMCU->CR = 0;
	hci_reset();

	LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
	HAL_SuspendTick();

	HAL_PWREx_DisableBLEActivityIT();
	HAL_PWREx_Disable802ActivityIT();

	HAL_PWREx_EnablePullUpPullDownConfig();

	HAL_PWREx_EnableGPIOPullDown(PWR_GPIO_A, GPIO_PIN_1);

	HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WU);

	HAL_PWREx_EnableWakeUpPin(PWR_WAKEUP_PIN1_HIGH,PWR_CORE_CPU1);

	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN2);
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN3);
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN4);
	HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN5);

	HAL_PWREx_DisableInternalWakeUpLine();
	HAL_PWREx_ClearWakeupFlag(PWR_FLAG_WU);

	LL_PWR_ClearFlag_WU();

	LL_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);
	LL_C2_PWR_SetPowerMode(LL_PWR_MODE_SHUTDOWN);


	LL_LPM_EnableDeepSleep();
	__WFI();

 

We have a button on pin A1 that we intend to wake from sleep mode, we intend to treat waking from sleep as a system reset so SHUTDOWN seemed like the best option. 

 

Our board draws 0.024A with the MCU active and 0.011A after attempting to enter shutdown mode. 

I also tried STOP_2 mode with the following code 

 

 while(1)
 {
 DBGMCU->CR = 0;
 HAL_SuspendTick();
 LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
 LL_C2_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
 SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
 __WFI();

 if(platform_gpio_read_pin(PLATFORM_GPIO_PWR_BUTTON) == 0)
 {
 NVIC_SystemReset();
 }
 }

 

 

In STOP2 power mode we measure an input current of 0.007A. 

 

In shutdown mode, all interrupts are ignored and the device wakes up only when our power button PA1 is pressed.

In STOP2 we get woken by any interrupt source, but go back to sleep unless it is the power button. 

The 2nd core does appear to go to sleep in both modes, we get disconnected from BLE on sleep and if sleep is entered during advertising then advertising stops. 

Can anyone give advice on entering SHUTDOWN mode correctly, or if we are doing so already, why we would be seeing lower currents in STOP2 vs SHUTDOWN?

 

 

 

1 reply

STTwo-32
Technical Moderator
November 5, 2024

Hello @LM.2 

For this implementation, I may suggest you take a look at the BLE_p2pServerThreadX example from the STM32CuebWB.taking a look at the stm32_lpm_if.c and stm32_lpm_if.h may help you understanding how to implement the different Low Power modes on your application.

Best Regards.

STTwo-32

LM.2
LM.2Author
Associate II
November 14, 2024

Hey @STTwo-32 I've been trying to get the example provided working on an Nucleo-wb55rg and only managed to enter a sleep mode after preventing the BLE application from starting (it disables sleep). Even then we were not noticing significant drops in power consumption. 0.28w -> 0.25w before and after entering the STANDBY state by directly calling UTIL_LPM_EnterLowPower();.  The stm32_lpm_if.c file also only appears to offer functions for entering sleep, stop_2 and standby states but not the shutdown state that we desire in our application. 

 

Can you give any feedback on properly entering the SHUTDOWN state?

Thank you.