cancel
Showing results for 
Search instead for 
Did you mean: 

Can't lock the RCC semaphore when exiting low power mode with BLE enabled

BabdCatha
Associate

Hello everyone, for one of my projects, I am trying to use an STM32WB55 (RGV6) to read data from the ADC and notify a phone through BLE.

 

I have been able to read from the ADC, send the relevant data and enter shutdown mode, before waiting 64 seconds for an RTC alarm to wake up the system and start the system again.

 

It works fine, until I try to enable the low power mode in the advertising phase. According to what I found in another question (https://community.st.com/s/question/0D50X0000BzuU4fSQE/ble-low-power-mode-stop2), I should be able to enter STOP2 mode when entering the idle phase of the sequencer. I tried running the provided code, and a few other things to do just that, but I kept running into the same issue.

 

First, here is the code (in app_entry.c) that I tried to enter low power modes when idling :

void UTIL_SEQ_Idle( void )
{
#if ( CFG_LPM_SUPPORTED == 1)
  UTIL_LPM_EnterLowPower();
#endif
  //UTIL_LPM_SetStopMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE);
  //UTIL_LPM_SetOffMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE);
  UTIL_LPM_EnterLowPower();
  //HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
  return;
}

However, when I compiled and ran my project, it stopped advertising after a few packets. I tried to look at the power consumption to find out if I was getting stuck in STOP mode and unable to wake up, but this was not the case. The program was stuck in a loop after an arbitrary number of BLE advertising packets.

 

Here is a picture of that phenomenon, with spikes corresponding to resets of the device.

 

0693W00000LzA28QAF.jpg 

To find more details on what was happening, I used the debugger to see what the program was doing, and what I found was that the program was getting stuck when exiting low power mode, more specifically at this line in smp32_lpm_if.c in the ExitLowPower function :

while( LL_HSEM_1StepLock( HSEM, CFG_HW_RCC_SEMID) );

I tried to disable this line, to make it a 2-step lock, but nothing so far has corrected the issue. All other uses of the CFG_HW_RCC_SEMID are in the same file, and are followed not far away by a release of the lock.

 

In the end, I have not yet been able to find what was preventing the lock operation from being completed, and have no more ideas on what to look for.

 

Thank you in advance for any tip or idea, if you need to, you can find the code for the whole project here : https://github.com/BabdCatha/STM32-ECG/tree/main/STM32WB55RGV6/STM32-ECG

2 REPLIES 2
Remy ISSALYS
ST Employee

Hello,

It's not possible to do shutdown when BLE is activated. To do shutdown, you must turn off the CPU2 before going shutdown mode and when you recover from shutdown, you need to do all the CPU2 initialization again before starting BLE activity.

When BLE is on, the low power mode which consume the less is STOP2.

You can look BLE_HeartRate example available in STM32CubeWB package which allows to do STOP2 low power mode:

https://www.st.com/en/embedded-software/stm32cubewb.html

Best Regards

Hi,

Thank you for your answer.

What I was trying to do was indeed to put the WB55 into STOP2 mode when idle, not shutdown mode, I should not even have mentioned shutdown since it was not relevant to the question.

I looked around the BLE_HeartRate code example, comparing it to mine, and after a few days, I think I found what was wrong with my project.

The Flash clock was set to 16MHz, when the CPU2 clock was set to 32MHz. Setting the Flash clock to 32MHz seems to have fixed my issue, as I can now enter and exit STOP2 mode when idle without any problem.

Thank you again for your answer !