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

Sleep mode

In working through understanding how sleep works with the SDK I ran into the following note for sd_app_evt_wait()

The application must ensure that the pended flag is cleared using sd_nvic_ClearPendingIRQ in order to sleep using this function. This is only necessary for disabled interrupts, as the interrupt handler will clear the pending flag automatically for enabled interrupts.

I am using nrf_pwr_mgmt_run() when the application is idle to put the system to sleep, which calls sd_app_evt_wait(). This looks fine except the above note leads me to think I need to add sd_nvic_ClearPendingIRQ() calls for all unused/disabled interrupts.

Some evidence of this is in nrf_pwr_mgmt_run() where the PWR_MGMT_FPU_SLEEP_PREPARE macro is used just before calling sd_app_evt_wait() to clear pending interrupts to avoid preventing the system from sleeping as the following comment notes:

* Clear FPU exceptions.
* Without this step, the FPU interrupt is marked as pending,
* preventing system from sleeping.

Do I need to add calls to sd_nvic_ClearPendingIRQ or does nrf_pwr_mgmt_run handle this in some way that I don't see?

Parents
  • Do I need to add calls to sd_nvic_ClearPendingIRQ

    Generally, you don’t need to do that. You will not get pending interrupt on a peripheral as long as intenset is not enabled. We are doing it for the FPU, yes, but that is because it’s behavior is a little different from the other peripherals. (The FPU interrupt will always set the pending flag (even if the interrupt is not enabled), you can read about this at the bottom of this page).

Reply
  • Do I need to add calls to sd_nvic_ClearPendingIRQ

    Generally, you don’t need to do that. You will not get pending interrupt on a peripheral as long as intenset is not enabled. We are doing it for the FPU, yes, but that is because it’s behavior is a little different from the other peripherals. (The FPU interrupt will always set the pending flag (even if the interrupt is not enabled), you can read about this at the bottom of this page).

Children
No Data
Related