2024-02-06 04:05 AM - edited 2024-02-08 09:49 AM
Hello,
I'm using bluenrg-lp with BLE stack initialized for Rx only, I set to GAP_OBSERVER_ROLE and the observation procedure is stopped, I'm trying to enter in sleep mode POWER_SAVE_LEVEL_STOP_WITH_TIMER based on example code :
WakeupSourceConfig_TypeDef wakeupIO = {0, 0, 0, 0};
PowerSaveLevels stopLevel;
HAL_VTIMER_Tick();
BLE_STACK_Tick();
NVMDB_Tick();
HAL_PWR_MNGR_Request(POWER_SAVE_LEVEL_STOP_WITH_TIMER, wakeupIO, &stopLevel);
printf("Exit from sleep mode %d.\r\n", stopLevel);
I added print in HAL_PWR_MNGR_Request() function :
final_level : 2, app_powerSave_level : 3, level : 2
final_level : 2, vtimer_powerSave_level : 2
final_level : 2, pka_level : 3
Exit from sleep mode 0.
It shows that the three parts agree for level 2 sleep mode but the final in 0 (RUN mode).
It goes in this condition (in HAL_PWR_MNGR_Request()) :
/* If for some reason the power save is skipped (i.e. wakeup source already active.....) */
if (RAM_VR.WakeupFromSleepFlag == 0) {
final_level = POWER_SAVE_LEVEL_RUNNING;
The "WakeupFromSleepFlag" is set to 1 only before main() is called.
How to get this variable to 1 ? or How to prevent this variable from going to 0 ?
Thanks
2024-02-08 09:48 AM
WakeupFromSleepFlag is set to 0 at the start of HAL_PWR_MNGR_Request() and WakeupFromSleepFlag is set to 1 only from startup_BlueNRG_LP.c :
int __low_level_init(void)
{
/* If the reset reason is a wakeup from DEEPSTOP restore the context */
if ((RCC->CSR == 0) && ((PWR->SR1 != 0)||(PWR->SR3 != 0))) {
RAM_VR.WakeupFromSleepFlag = 1; /* A wakeup from DEEPSTOP occurred */
CSR bits is set to 1 if a reset occured (RM0479 6.6.14), SR1 and SR3 bits are set to 1 if a wakeup occured (RM0479 5.6.5).
I also print before and after HAL_PWR_MNGR_Request() output of HAL_PWR_MNGR_WakeupSource() function which is SR1 and SR3 registers in a 32 bits value, all bits are 0.
From these elements, I understand that I can't get a deepstop mode because there was no wakeup before ?
2024-02-14 06:15 AM
hello @Sebastien DENOUAL
Could you help me to understand how "WakeupFromSleepFlag" works please ? and why RAM_VR.WakeupFromSleepFlag is reset ?