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

Maximal power efficiency in main loop - further question

Hi,

I asked previously about power efficiency for the NRF52840 SDK version V15 (https://devzone.nordicsemi.com/f/nordic-q-a/36083/maximal-power-efficiency-in-main-loop).

At that time I used the timer to poll the SPI using SPIM and timer event callbacks. I got the info that all I need is the main loop:

     for (;;) sd_app_evt_wait();

I would like to add incoming interrupt callbacks (using GPIOs) while keeping power management efficient.

Do I need to change my main loop?

Thanks,

Daniel

Parents
  • Hi,

    Do I need to change my main loop?

    No. After the CPU is done with the interrupt handler, it will go back to main context and go to sleep.

    Note that if you are using the nrf_log module, you might want to process pending log operations before going to sleep using NRF_LOG_PROCESS().

    Note that in SDK 15, the BLE examples mostly uses the power management module. So it typically looks like this:

        // Enter main loop.
        for (;;)
        {
            idle_state_handle();
        }

    where idle_state_handle() is defined as:

    /**@brief Function for handling the idle state (main loop).
     *
     * @details Handle any pending log operation(s), then sleep until the next event occurs.
     */
    static void idle_state_handle(void)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            nrf_pwr_mgmt_run();
        }
    }

Reply
  • Hi,

    Do I need to change my main loop?

    No. After the CPU is done with the interrupt handler, it will go back to main context and go to sleep.

    Note that if you are using the nrf_log module, you might want to process pending log operations before going to sleep using NRF_LOG_PROCESS().

    Note that in SDK 15, the BLE examples mostly uses the power management module. So it typically looks like this:

        // Enter main loop.
        for (;;)
        {
            idle_state_handle();
        }

    where idle_state_handle() is defined as:

    /**@brief Function for handling the idle state (main loop).
     *
     * @details Handle any pending log operation(s), then sleep until the next event occurs.
     */
    static void idle_state_handle(void)
    {
        if (NRF_LOG_PROCESS() == false)
        {
            nrf_pwr_mgmt_run();
        }
    }

Children
Related