2022-11-04 06:36 AM
Hello
On one hand I have built an application running FreeRTOS and BLE Device with custom services, in which I also use Virtual Com Port communication, Analog measurements and some digital I/Os. This one is running perfectly.
On the other hand, as I need to go into STANDBY mode, I have tried and adapted the example program called "PWR_EnterStandbyMode". I enter in STANDBY mode after a while (30sec) and then use an external WAKEUP pin to quit STANDBY mode and restart the application. This one also runs well.
So, I tried to integrate the STANDBY management in my whole application using the same methods. Unfortunately, it doesn't work correctly and I can't understand why.
Here is the result and what happen :
Could someone give me explanation and what may be the reason ?
What should I do ?
Do I neek to kill tasks ?
Is there something particular to do for CPU2 going in standby ?
Is there something particular to do for CPU2 restart after standby ?
Here after a description of my application :
Code for "Configure_PWR" :
void Configure_PWR(void)
{
int i;
g_StandBy=0;
/* Check if the system was resumed from Standby mode */
/* Note: On STM32WB, both CPU1 and CPU2 must be in Standby mode to set the entire system in Standby mode */
if( (LL_PWR_IsActiveFlag_C1SB() != 0) && (LL_PWR_IsActiveFlag_C2SB() != 0) )
{
/* Clear Standby flag */
LL_PWR_ClearFlag_C1STOP_C1STB();
LL_PWR_ClearFlag_C1STOP_C1STB();
// If we resume from STBY then flash LED, then set the global variable g_StandBy
for(i=0;i<10;i++)
{
LL_GPIO_SetOutputPin(GPIOB, LL_GPIO_PIN_0);
HAL_Delay(50);
LL_GPIO_ResetOutputPin(GPIOB, LL_GPIO_PIN_0);
HAL_Delay(50);
}
g_StandBy=1;
}
/* Specific procedure on STM32WB, in case of initial power-up and RF stack no started */
/* Note: This procedure is required when user application wants to request */
/* a low-power mode in the particular case: */
/* - RF stack not started: On STM32WB, system low-power mode is fixed */
/* by the deepest low-power modes of each sub-system (CPU1, */
/* CPU2, RF). */
/* Standard case is RF stack started and managing low-power modes */
/* of CPU2 and RF. */
/* In case of RF stack not started, CPU2 low-power mode must be */
/* forced to the lowest level. This allows to require all system */
/* low-power modes using only PWR for CPU1. */
/* low-power mode. */
/* - Initial power-up: In case of power-on reset, CPU2 low-power mode */
/* has its reset value and must be set. */
/* In case of system is resumed from low-power mode standby */
/* or shutdown, configuration of PWR parameters related to CPU2 are */
/* retained and must not modified (This check is required in case */
/* of RF stack started afterwards and to not overwritte its */
/* low-power configuration). */
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);
}
/* Check and Clear the Wakeup flag */
if (LL_PWR_IsActiveFlag_WU2() != 0)
{
LL_PWR_ClearFlag_WU2();
}
}
Code for "EnterStandbyMode" :
void EnterStandbyMode(void)
{
/* Disable all used wakeup sources */
LL_PWR_DisableWakeUpPin(LL_PWR_WAKEUP_PIN2);
/* Clear all wake up Flag */
LL_PWR_ClearFlag_WU();
/* Enable pull up on wakeup pin */
/* Note: Setting not mandatory but recommended since there is no external pulling resistor on pin PC13 on STM32WB Nucleo board */
LL_PWR_EnableGPIOPullUp(LL_PWR_GPIO_C, LL_PWR_GPIO_BIT_13);
/* Enable pull-up and pull-down configuration for CPU1 */
LL_PWR_EnablePUPDCfg();
/* Set wakeup pin polarity */
LL_PWR_SetWakeUpPinPolarityLow(LL_PWR_WAKEUP_PIN2);
/* Enable wakeup pin */
LL_PWR_EnableWakeUpPin(LL_PWR_WAKEUP_PIN2);
/* As default User push-button (SW1) state is high level, need to clear all wake up Flag again */
LL_PWR_ClearFlag_WU();
// Request to enter Standby mode
// Following procedure describe in STM32WBxx Reference Manual
// See PWR part, section Low-power modes, Standby mode
/* Set Standby mode when CPU enters deepsleep */
LL_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
/* Set SLEEPDEEP bit of Cortex System Control Register */
LL_LPM_EnableDeepSleep();
/* This option is used to ensure that store operations are completed */
#if defined ( __CC_ARM)
__force_stores();
#endif
/* Request Wait For Interrupt */
__WFI();
}
Thank you in advance for your help and recommendations.
A nice day to all !
Patrick
2022-11-09 06:00 AM
Hello,
On STM32WB55, according to the application note AN5289, standby mode isn't supported when RF is active:
STOP2 is the deepest low power mode supported when RF is active. When the user application has to enter Standby mode, it must first stop all RF activities, and fully re-initialize CPU2 when coming out of Standby mode. The user application may use the full non secure SRAM2a to store its own content (that needs to be retained in Standby mode).
A new example is available on STM32 HotSpot Github STM32WB-BLE-standby which allow to have BLE activity and then enter in standby mode and wake up the system from wake-up pin.
Best Regards
2022-11-09 07:25 AM
The example still has some issues reported there:
The wake-up flags are cleared correctly and I guess putting the WFI instruction in a loop is not appropriate for wireless devices, but other issues are still relevant: the PWR register write after LL_PWR_SetPowerMode() is not ensured to be complete, DBGMCU_CR is not reset and __force_stores() works only for ARM v5 compiler.
2022-11-11 11:48 PM
Hello
Thank's for your replies,
Remy, I had a look on STM32WB-BLE-standby example, but I can't find any source code with the main application. Are you sure the archive Git is full ?
PIranha, as aI understand, these functions have still issues ? I will try to read and test deeper with your related topics in a few day and let you informed...
Have a nice day !
2022-11-14 12:47 AM
Hello,
Yes, the Git is full, the source code of project is under this folder. This project works as expected to go in standby mode and wake up on wake-up pin. I will ask the dev team to see Piranha remarks.
Best Regards
2022-11-14 11:11 PM
2022-11-25 03:12 AM
Helo again,
I'm back with this topic...
In fact, the exampl you suggest works well in its own context. I mean, using the sequencer.
On my side I use FreeRTOS which is quiet diferent, butmy main problem is the SEQ application is not so easy to read and understand thant FreeRTOS. So I can't understand what are the steps needed to commplete the standby enter and resume from.
Where can I found more explanation, example and comments ?
In fact, I guess that my problem comes from the fact that I use FreeRTOS, and the way to manage LP mode is quiet different...
THank's again for help.
PAtrick
2022-11-26 10:39 AM
The sequencer and timer server are explained in the same AN5289 sections 4.4 and 4.5 respectively.
2022-11-28 10:52 PM
My question was : How should I do under FreeRTOS ?
THank's again
2022-11-30 02:24 AM
Hello,
You can look BLE_HeartRateFreeRTOS example available in STM32CubeWB package, if you want a BLE example using FreeRTOS. If the RF is active, you can't go in standby mode on WB55, so before entering in standby mode, you shall stop all RF activities.
According to RM0434, All registers are reset after wakeup from Standby except for PWR control register 3 (PWR_CR3).
Best Regards