STM32WB55 CPU2 doesn't restart after STANDBY mode enterring
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 :
- When enterring in STBY mode, the program restarts directly from the beginning, just like a reset. Why that ?
- Then, when I wake it up using the appropriate pin, it blocks on the CPU2 start waiting for APP_FLAG_CPU2_INITIALIZED and APP_FLAG_WIRELESS_FW_RUNNING.
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 :
- 3 tasks running on FreeRTOS :
- Main task operating all measurements and main management
- Communication task for USB-VCP communication
- BLE task in charge of services and characteristics management (always advertising, answer to connection from central device without pairing)
- On init, in the main I perform all the initializations, and call a "Configure_PWR" function as described here after, then starts all the tasks.
- In the main task, on a Timer elapased after 1 minute running, I call a "EnterStandbyMode" function also described here after.
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