cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WB55: Implement Standby mode in a BLE application

MGonzalez
Associate II

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.

4 REPLIES 4
Remi QUINTIN
ST Employee

Standby is only possible when the RF activity is stopped.

Then when exiting from the standby mode, the full initialization process has to be done.

C2BOOT will not restart the CPU2 core. This bit is only functional out of reset, not out of the standby mode.

So you have to perform all the initialization steps in a similar way as after a power down.

MGonzalez
Associate II

Yes, indeed I stop the advertising before going to Standby. I measured the power consumption and the system enters it successfully.

The same system initialization as in reset is performed out of the standby mode, but the program is stuck waiting a response from CPU2.

So, if the C2BOOT does not restart CPU2 out of standby, how can it be done? I thought that the EXTI mechanism described in the function above would be enough but it does not seem to be working.

​Hello,

There should not be more to do than running again the startup flow on CPU1.

This will call at some time HW_IPCC_Enable() and the CPU1 will be woken up due to the EXTI setting done in that function as the C2BOOT will not wakeup the CPU2 when out of standby.

As long as you should consider to reconfigure everything when out of standby, there is another alternative that may fit your application.

When you exit standby on CPU1, you could immediately call NVIC_SystemReset().

This will reset one more time the device but in that case, you are back to a state very closed to Power ON and C2BOOT will be able to wakeup CPU1.

Regards.

Hello,

Thank you for your answer. The NVIC_SystemReset function worked, though it is not the most optimal solution.

For the rest, I think there must be a configuration missing because the startup code is the same after a reset than when out of standby. The HW_IPCC_Enable() is called in this code, but the CPU2 is not woken up by the EXTI setting.