This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

does app_timer timeout interrupt wake nRF51822 from __WFE ?

Our project uses nRF51822 with SDK12.3.0 and s130. We are using  app_timer_appsh.h and app_scheduler.h to make a "UTC timer" by counting a static variable each 1S timeout . Now we need implement power saver to project. Then we decide to use system ON low power mode ( this function sd_app_evt_wait() ) when event BLE_ADV_EVT_IDLE happen. After add power saver to project, "UTC timer" runs wrong. my question is:

+ Can app_timer timeout interrupt can wake system from __WFE() ?

+ when waking from __WFE, ram is retain or not ?

+ Is there any event from softdevice make we know that cpu is in idle time to push device to low power mode ?

Thank you so much!

Parents
  • Hi,

    Can app_timer timeout interrupt can wake system from __WFE() ?

     Yes, the system will wake up on the RTC interrupt (the timer library relies on RTC1).

    when waking from __WFE, ram is retain or not ?

     RAM is always retained in this case (system ON low power mode).

    Is there any event from softdevice make we know that cpu is in idle time to push device to low power mode ?

    No, there is no need. The SoftDevice will only do work after an interrupt, so the device will always wake up from system ON low power mode when the SoftDevie has work to do. If you refer to most BLE SDK examples you will see that the examples always call sd_app_evt_wait() in the main loop. This is the recommended way, and ensures that the device always enters sleep mode after each wake up as soon as any interrupts are handled.

    Note that you should not call __WFE() directly, as it is called from sd_app_evt_wait(). Just call sd_app_evt_wait() from the main loop as is done in for instance the Glucose Application example (from the power_manage() function).

  • Hi Einar Thorsud,

    Thanks for your support, I have put sd_app_evt_wait() to main loop then it's saved my project's power consumption. Should I  use sd_app_evt_wait() with sd_power_mode_set() as below?

    /**@brief Function for placing the application in low power state while waiting for events.
     */
    void power_manage(void)
    {
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
        sd_power_mode_set( NRF_POWER_MODE_LOWPWR );
    }
    

    Thanks!

    Best Regards 

Reply
  • Hi Einar Thorsud,

    Thanks for your support, I have put sd_app_evt_wait() to main loop then it's saved my project's power consumption. Should I  use sd_app_evt_wait() with sd_power_mode_set() as below?

    /**@brief Function for placing the application in low power state while waiting for events.
     */
    void power_manage(void)
    {
        uint32_t err_code = sd_app_evt_wait();
        APP_ERROR_CHECK(err_code);
        sd_power_mode_set( NRF_POWER_MODE_LOWPWR );
    }
    

    Thanks!

    Best Regards 

Children
Related