STM32WB55: Implement Standby mode in a BLE application
I am working on a project based on the BLE Beacon application in the P-NUCLEO-WB55.Nucleo board.
After broadcasting for some time, it is stopped and the system enters successfully Standby mode, from which it will wake up with the RTC.
The RTC wakes up CPU1 as expected but the program gets stuck after the initialization. After some debugging, I think the problem is that CPU2 does not enter Run mode, instead it stays at Stop mode waiting for a wake-up source (cfr. CPU2 boot options on Reference Manual RM0434), so CPU1 stays stuck waiting a response from CPU2 before initializing the BLE application.
There is this function in the auto-generated code from CubeMX that seems to solve exactly this problem:
void HW_IPCC_Enable( void )
{
/**
* When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2
*/
LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 );
LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 );
/**
* In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2.
* In that case, to keep the mechanism transparent to the user application, it shall call the system command
* SHCI_C2_Reinit( ) before jumping to the application.
* When the CPU2 receives that command, it waits for its event input to be set to restart the CPU2 firmware.
* This is required because once C2BOOT has been set once, a clear/set on C2BOOT has no effect.
* When SHCI_C2_Reinit( ) is not called, generating an event to the CPU2 does not have any effect
* So, by default, the application shall both set the event flag and set the C2BOOT bit.
*/
__SEV( ); /* Set the internal event flag and send an event to the CPU2 */
__WFE( ); /* Clear the internal event flag */
LL_PWR_EnableBootC2( );
return;
}From what I can understand, using this function will create an event that will wake up CPU2 when the device is out of standby mode. Are there more configurations to be done so this mechanism works?
Thanks in advance for your help.