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

sd_app_evt_wait() does not put the cpu in sleep

Hi,

I have a similar problem as described in

devzone.nordicsemi.com/.../

I have eliminated my program to be:

int main(void) {
  setupLEDPins();
  BluetoothPeripheral::instance().initialize();
  int counter = 0;
  while (1) {
    delayMs(100);
    pinToggle(LED_GREEN);
    if (counter == 10) {
      pinSet(LED_ORANGE);
      sd_app_evt_wait();
    }
    counter++;
  }
}

As you see this code basically toggles a LED 10 times and then lits an orange LED and put the cpu to sleep with sd_app_evt_wait which should stop the LED from blinking.

However, when I run this code the green LED blinks and after a while the orange LED comes on but after that the green LED keeps blinking! I have tried putting delays before and after and also calling the sd_app_evt_wait() multiple times in a row but nothing helps.

What have I missed?

Thanks!

Parents
  • what does

    BluetoothPeripheral::instance().initialize();
    

    do? Does that start an instance of the bluetooth peripheral, enable the softdevice etc etc? If so then the softdevice is constantly going to be generating events and interrupts which will break out of your sd_app_evt_wait() (which is really just __wfe).

Reply
  • what does

    BluetoothPeripheral::instance().initialize();
    

    do? Does that start an instance of the bluetooth peripheral, enable the softdevice etc etc? If so then the softdevice is constantly going to be generating events and interrupts which will break out of your sd_app_evt_wait() (which is really just __wfe).

Children
  • Ok, thanks for your answer! So how do I stop the softdevice from generating events and interrupts? E.g. how to I put the cpu to sleep with the softdevice enabled?