Unable to use Standby Mode with STM32/WPAN BLE Package
Board: STM32WB55
Software: STM32CubeIDE, STM32_WPAN BLE as Custom p2p server
Background: Have a test bench set up to check entering Standby Mode with additional features we want to use on our project before implementing it. Have been adding in our features and Standby Mode has been entered fine with good power consumption measured. I left the STM32_WPAN BLE package to last to add into the test project. This is my (edited) function WIP so far that is called when a button is pressed, using a flag system so not within the interrupt:
static void Enter_Standby_Mode() {
/* Flash Green LEDs to signal Shut Down and ensure all are off */
/* Specific procedure on STM32WB, in case of initial power-up and RF stack no started */
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_STANDBY);
}
/* Clear the RTC Wake UP (WU) flag */
__HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(&hrtc, RTC_FLAG_WUTF);
/* Clear the Wake Up FLAG */
__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU);
/* Set new RTC Wake Up Timer ~10s */
if (HAL_RTCEx_SetWakeUpTimer_IT(&hrtc, 0x5AAA, RTC_WAKEUPCLOCK_RTCCLK_DIV16) != HAL_OK) {
Error_Handler();
}
/* Set CPU2 into Standby Mode */
LL_C2_PWR_SetPowerMode(LL_PWR_MODE_STANDBY);
/* Allow Low-Power Manager to Enter Standby State?
* This links to a function calling UTIL_LPM_SetOffMode(1 << CFG_LPM_APP_BLE,
UTIL_LPM_ENABLE);*/
BLE_Enable_Standby();
/* Enter the Standby mode */
HAL_PWR_EnterSTANDBYMode();
/* Program should never reach this point (program restart when exiting from standby mode) */
Error_Handler();
}
Problem: This works fine, as per several examples, re-awakening form the RTC WU timer. However, simply adding in the STM32_WPAN package for BLE and generating the files with CubeMX, stops Standby Mode from working and it will now proceed to the Error_Handler.
I have scanned through app_conf.h for anything related and nothing seems to effect the outcome that is not the same in examples I have seen. I cannot seem to find the missing piece of this puzzle, I am not using debugger when expecting the power mode to change. The LPM and CPU2 are set into their respective low power states that should, as far as I am aware, allow the whole system to enter Standby. I have double checked registers during debugging and they are all set as expected in the reference manual,
Any clues would be much appreciated,
Thanks