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!

  • 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 

  • hi.... frankie 

    how you are putting the device in sleep mode 

    is it working fine ?

    help me out

  • Hi,

    This looks good, but you should remove the call to sd_power_mode_set(). There is no need to set it repeatedly, and most probably you never have to set it (unless you set it to NRF_POWER_MODE_CONSTLAT earlier) NRF_POWER_MODE_LOWPWR is the default mode.

  • You can refer to any BLE example in the SDK to see how to put the device in low power mode. Essentially you just need a few steps:

    • Disable any peripherals you don't need while in sleep.
    • Make sure that your application has a main loop which always calls sd_app_evt_wait(), either directly or via a library.

    A common mistake for not seeing low current consumption is if you have UART logging enabled, so disabling logging in sdk_config.h is important. This is a consequence of the first bullet point above.

Related