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

application fails to wake up from sleep

Before starting advertising, we want to write some configuration information to NVM. In order to write to NVM, we first call sd_flash_page_erase and wait for the response from the softDevice. While waiting, we call sd_app_evt_wait. We expect to receive the SWI2 interrupt indicating that the erase is complete.

On most of our boards, this happens correctly, within ~50ms, and we have no subsequent problem. However, on some boards the SWI2 interrupt doesn’t fire until after the NRF is woken up by an external interrupt from a different processor, several seconds later. Our conclusion is that we are asleep (NRF_POWER_MODE_LOWPWR). We know we have interrupts configured correctly because it works fine on some boards, so how could we be stuck in sleep?

In debugging this issue, we also noticed that the RTC1 interrupt stops firing during the time the NRF is asleep. We expect the processor to wake up every 125ms and service RTC1, but this interrupt also doesn’t fire until we get an external wakeup from the host processor.

Another confusing element is that we made a seemingly unrelated change that seems to “fix” both problems above. In our initialization sequence, we were calling sd_radio_notification_cfg_set very early on, before writing to NVM. When we moved the call to happen AFTER writing to NVM, the above problems went away. But considering that we’re writing to NVM before starting advertising, I can’t understand how this change would have any effect.

How can radio notifications affect whether the RTC1 interrupt fires or whether the NRF gets stuck in sleep?

Parents
  • Tags: nrf51822, s110, softdevice 6.0.0.

    This whole problem happens during our startup process before we start advertising (sd_ble_gap_adv_start). We are not confident that our fix truly resolves the issue, or just masks it.

    We don't start advertising until the flash erase/write is complete (in the code both before and after the "fix"). Now we've moved radio notification initialization to a point later in the process, but it is also before we start advertising. I don't expect that sd_radio_notification_cfg_set should cause any radio activity if we haven't yet turned on advertising, correct? So it’s hard to see how it can affect writes to NVM, and it's hard to be convinced that our fix is really a fix.

Reply
  • Tags: nrf51822, s110, softdevice 6.0.0.

    This whole problem happens during our startup process before we start advertising (sd_ble_gap_adv_start). We are not confident that our fix truly resolves the issue, or just masks it.

    We don't start advertising until the flash erase/write is complete (in the code both before and after the "fix"). Now we've moved radio notification initialization to a point later in the process, but it is also before we start advertising. I don't expect that sd_radio_notification_cfg_set should cause any radio activity if we haven't yet turned on advertising, correct? So it’s hard to see how it can affect writes to NVM, and it's hard to be convinced that our fix is really a fix.

Children
No Data
Related