cancel
Showing results for 
Search instead for 
Did you mean: 

BLE Operation in Low Power Modes on STM32WB

JR2963
Senior II

Hi,

I'm not sure if I fully understand how the low-power mode works with active BLE on the STM32WB. I have an application using FreeRTOS and the BLE stack. I have set up advertising and am able to send and receive data over BLE. This works fine. When CPU1 enters Sleep mode — since it has no tasks to handle — BLE seems to work correctly. However, if it enters STOP2 mode instead of Sleep, it stops working properly. 

In RM0434, it is stated that the system will enter low-power mode only when all three subsystems allow it (CPU1, CPU2, Radio Subsystem). A few lines below, it says that these three subsystems can enter and exit low-power mode on their own (page 154).

At the same time, the table here shows that CPU2 cannot run in STOP mode, but the radio can wake up the entire system if needed.

 

JR2963_0-1726493511723.png

In AN5289, it is mentioned that the wireless firmware automatically sets the best low-power mode configuration for CPU2 as soon as CPU2 is started.

In the HeartRate Monitor example, `UTIL_LPM_SetOffMode(1 << CFG_LPM_APP, UTIL_LPM_DISABLE);` is called before initializing BLE, and OffMode is enabled again after the initialization is complete.

Questions:
1) If I have BLE advertising set with a period of around 100 ms, can I put CPU1 into STOP(2) mode? Will CPU2 and the radio handle the operations on their own while CPU1 is in STOP mode? If so, will they wake up CPU1 as well? 

2) If someone has already connected to my device via BLE, can I also put CPU1 into STOP mode?

3) To entering STOP mode I use funcion from example - hope it is correct?

 

static void EnterLowPower(void)
{
  /**
   * This function is called from CRITICAL SECTION
   */

  while(LL_HSEM_1StepLock(HSEM, CFG_HW_RCC_SEMID));

  if (! LL_HSEM_1StepLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID))
  {
    if(LL_PWR_IsActiveFlag_C2DS() || LL_PWR_IsActiveFlag_C2SB())
    {
      /* Release ENTRY_STOP_MODE semaphore */
      LL_HSEM_ReleaseLock(HSEM, CFG_HW_ENTRY_STOP_MODE_SEMID, 0);

      Switch_On_HSI();
      __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_0);
    }
  }
  else
  {
    Switch_On_HSI();
    __HAL_FLASH_SET_LATENCY(FLASH_LATENCY_0);
  }

  /* Release RCC semaphore */
  LL_HSEM_ReleaseLock(HSEM, CFG_HW_RCC_SEMID, 0);

  return;
}

 

 and finally enter STOP:

 

LL_PWR_SetPowerMode(LL_PWR_MODE_STOP2);
LL_LPM_EnableDeepSleep(); 
 __WFI();

 

 @STTwo-32  Thank you very much for help.

0 REPLIES 0