`nrf_pwr_mgmt_run` returns immediately, and the return value is 0.

I used nRF52840 with nRF5 SDK 17.1.0

Also use freeRTOS from example "ble_app_hrs_freertos"

I need implement System-On mode deepsleep mode.
So I use nrf_pwr_mgmt_run API in my main task.

bool System_Sleep(void)
{
Log("%s: +", __func__);

uint32_t ret = 0;

Log("%s: enter real sleep", __func__);

stopSleepTimer();

vTaskSuspendAll();

//taskDISABLE_INTERRUPTS(); // if enable this, will block in nrf_pwr_mgmt_run and then does not wakeup by everthing.

RegisterWakeupSource();

{
nrf_pwr_mgmt_run();
//ret = sd_app_evt_wait();

sd_evt_get(&ret);
}
UnregisterWakeupSource();

taskENABLE_INTERRUPTS();

xTaskResumeAll();

resetSleepTimer();

Log("%s: ret %d -", __func__, ret);
return true;
}

But "nrf_pwr_mgmt_run" API will return immediately,

sd_evt_get value is '0'.

how to enter deepsleep mode with System On mode?

Parents
  • Note that support for this SDK stopped quite a while ago, you want to upgrade to NCS SDK.

    What logging method do you use? Logging UART may still be active and would keep the MCU core from sleeping.

    Also check if nrf_pwr_mgmt_run actually knows how to skip FPU exceptions (see other sample code how). Don't remember the RTOS code well enough here, but pending FPU exceptions will keep the core running. 

Reply
  • Note that support for this SDK stopped quite a while ago, you want to upgrade to NCS SDK.

    What logging method do you use? Logging UART may still be active and would keep the MCU core from sleeping.

    Also check if nrf_pwr_mgmt_run actually knows how to skip FPU exceptions (see other sample code how). Don't remember the RTOS code well enough here, but pending FPU exceptions will keep the core running. 

Children
Related