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

Problem with sd_app_evt_wait() after sd_clock_hfclk_request()

Hi there

After initializing the SoftDevice S132 V6.1.0, I request the HF crystal by calling the function sd_clock_hfclk_request():

uint32 SD_HF_crystal_start(void)
{
   uint32 sd_stat;
   uint32 running;

   // Request the start of the HF crystal oscillator
   sd_stat = sd_clock_hfclk_request();
   if (sd_stat) {return sd_stat;}

   // Workaround for errata 68 of nRF52832 rev. 1
   QT_wait_us(HFXO_STABLE_TIME_US);

   // Wait until the HF crystal has started
   running = 0;
   while (running == 0)
   {
      sd_stat = sd_clock_hfclk_is_running(&running);
      if (sd_stat) {return sd_stat;}
   }

   return NRF_SUCCESS;
}

Later in the code, after a BLE connection has been established (nRF being in peripheral role), I'm calling sd_app_evt_wait() in a loop to save power until the connection has been terminated again.

Now, the problem occurred that the function sd_app_evt_wait() returns immediately at every call. But when I clear the SD_EVT_IRQn after the HF crystal has been started, the function sd_app_evt_wait() remains sleeping as expected.

   // Enable the HF crystal
   sd_stat = SD_HF_crystal_start();
   if (sd_stat) {return sd_stat;}

   // Clear the SoftDevice event IRQ
   NVIC_ClearPendingIRQ(SD_EVT_IRQn);

I've read that sd_app_evt_wait() returns immediately when an event is pending, but I would have expected that the nRF enters the low power mode at the next call of this function. Did I get this wrong? Why does starting the HF crystal prevent the nRF from entering System ON low power mode? Do you know this behavior? 

Many thanks in advance.

Best regards

Parents Reply Children
Related