cancel
Showing results for 
Search instead for 
Did you mean: 

Can Stop mode or any low power mode be used with BLE with Sequencer (present in While(1))?

GBehe
Associate III

Hi, I have STM32WB55CE chip and want to use stop mode or any other low power mode along with BLE + sequencer active. I tried to implement stop mode in while 1 outside sequencer. But it does not work. If I enable the LPM mode in BLE configuration part(in Cube MX part of Cube IDE), I observed that the stop mode inside sequencer works and exits from sleep, but within very less time.

If we need to stop all RF activities before going to stop mode, how can we do it?

Also can anybody share a document on Sequencer to understand its working?

Thank you..

4 REPLIES 4
Christophe Arnal
ST Employee

​​Hello,

Generally speaking, you should not implement anything else than UTIL_SEQ_Run() in the while(1) loop from the main.c. The only case when this would be fine is when the low power mode is disabled and the CPU stays in RUN mode.

The reason is that all code added there is unkown from the sequencer that executes UTIL_SEQ_Run() as long as there are pending tasks. When there is no more tasks pending, it calls UTIL_SEQ_Idle() which in turn calls UTIL_LPM_EnterLowPower() that may stop the CPU. So, the code added after UTIL_SEQ_Run() is executed only on the next wakeup which is likely not something you want to do.

The low power mode should be implemented when there is no more backgound tasks to be executed. In that case, the sequencer calls UTIL_SEQ_Idle() (in critical section) where you should enter in low power mode ( as we are doing in all our examples).

When implementing low power mode on CPU1, you shall not worry about activity on CPU2 driving the RF activity. You should implement the low power mode in the same way you will do on any single core STM32 plaform.

The way to decide whether you want to enter low power mode or not on CPU1 does not depend on CPU2 activity but when the decision is taken to enter low power mode on CPU1, there are some semaphores to be checked on entry and exit low power mode.

The algorithm is described in AN5289 rev4 (chapter 4.3 Shared peripherals) and implemented in stm32_lpm.if.c

It is strongly recommended to fine tune this file to your needs. The current implementation uses HSE as system clock and you just need to change that part of code if you need to use another system clock.

There are some descritpions of the Sequencer in AN5289 rev4 - chapter 4.4.

Regards.

GBehe
Associate III

Hi Christophe.

I tried to utilize the stm32_lpm.if.c file to implement stop mode as below. I have a LPTIM2 interrupt on every 5 sec running to wake up from LPM and send a notification. I want to wake the CPU up every 5 sec to send the notification and go back to sleep again.

void PWR_EnterStopMode( void )

{

/* USER CODE BEGIN PWR_EnterStopMode */

HAL_SuspendTick();

HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);

/* USER CODE END PWR_EnterStopMode */

}

void PWR_ExitStopMode( void )

{

/* USER CODE BEGIN PWR_ExitStopMode */

HAL_Init();

SystemClock_Config();

HAL_ResumeTick();

/* USER CODE END PWR_ExitStopMode */

}

But still behaves like the stop mode is not implemented. If it's not the correct way, is there some other way to implement it?

I also have doubt that there can be interrupts due to timer server effecting here.

Thank you.

Christophe Arnal
ST Employee

​Hello,

In your current implementation, you are missing all semaphores checking so you will likely suffer collision with the CPU2.

I would recommend following steps :

1/ Try the Heart Rate example as delivered for the Firmware package. It is configured by default to obtain best power consumption.

Check that you are able to enter Stop Mode2. During Radio Idle Time, you should be in the range of 3.6uA.

If this is not the case, I believe either the board configuration or the measurement tool is not correct

2/ Use HSE as system clock in your application. In that case, you can use the impementation of stm32_lpm.if.c with no modification. Just call UTIL_LPM_EnterLowPower() in the idle task. ( ie UTIL_SEQ_Idle() when using the sequencer)

At this stage, as long as previous test was successfull which shows board configuration and measurement tool are fine, you should be able to enter Stop Mode 2 with correct power consumption

3/ In case you need to use anything else than HSE as system clock ( can be only either MSI @32Mhz or PLL@64Mhz as you need to commit 32Mhw to CPU2),

You need to update only the following section in the function PWR_ExitStopMode() in stm32_lpm_if.c

    LL_RCC_HSE_Enable( );
    while(!LL_RCC_HSE_IsReady( ));
    LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSE);
    while (LL_RCC_GetSysClkSource( ) != LL_RCC_SYS_CLKSOURCE_STATUS_HSE);

This is where you may need to configure MSI or restart the PLL and use it.

There is no reason to change the implementation of PWR_EnterStopMode() unless you need to use something else that Stop Mode 2 ( eg Stop Mode 1 or 2). In that case, just update the line

LL_PWR_SetPowerMode( LL_PWR_MODE_STOP2 );

Note:

HAL_Init() is useless out of stop mode.

SystemClock_Config(); may be called to restore clock configuration. However, I would not recomment to go with it because the code is running in critical section and I believe SystemClock_Config();  is a bit long ( that od course depend on your own latency requirement, from a BLE application point of view, there are no constraints on the CPU1 application). It will reconfigure most registers which content are not lost so that it would be a waste of time.

As you could see, restarting HSE in our example is few lines. Restarting either MSI or PLL should be very similar.

Regards.

Hello

Sorry for jumping into discussion but I just measured the consumption in HeartRate Example (STM32Cube_FW_WB_V1.10.0\Projects\P-NUCLEO-WB55.USBDongle\Applications\BLE\BLE_HeartRate)

but no where I could see 3.6uA with the default options. You mentioned about board configuration or tooling to be incorrect. Where do you think I might be doing wrong given that it`s usb dongle hardware and measuring is over x-nucleo-lpm01a ?

Thanks

0693W000006HEufQAG.jpg