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

How to knew, what cause event after sd_app_evt_wait()?

Hi,

I want to put my nrf52832 into the low-power mode. I select SYSTEM ON with low-power (instead of SYSTEM OFF) in order to overcome reset. In order to do it I call sd_app_evt_wait(), but after that device immediately wakeup. Before calling this function, I've disabled all interrupts, beside gpiote. I want to use gpio event to wakeup. How to understand, what event causing wake-up?


Also, I try to make some debug, to find event source. I use this code:

            printf("evt id before = %d\n", sd_evt_get(&evt_id));
            sd_app_evt_wait();
            printf("evt id after = %d\n", sd_evt_get(&evt_id));

In terminal I obtain:
evt id before = 5
evt id after = 5

evt id = 5 it is NRF_EVT_RADIO_CANCELED
So, before sd_app_evt_wait(), I call sd_nvic_ClearPendingIRQ(RADIO_IRQn), but it is not help.
I use SDK 15.2, Softdevice s132 6.1.0

Parents Reply Children
  • Sorry for so long delay, I skipped notification about update in this thread. You can see in the first post that I use SDK 15.2 , softdevice s132 6.1.0.

    My application is based on ble_app_template. I try to go to sleep in advertising event handler in case of BLE_ADV_EVT_IDLE event. In my application I use 1 TIMER, SPI0, SPI1 through PPI from timer event, RTC and SPI2 for sd card and also GPIOTE. Before going to sleep I disable RTC, PPI and TIMER.

  • When you put the CPU to sleep do you have any radio activity ? Like advertising, in a connection ? 

    When you call sd_evt_get(&evt_id) please make sure that it's return NRF_SUCCESS. You can be waken up not because of softdevice's event. Please make sure it's not from one of your peripheral, like SPI, RTC, TIMER. 

     My suggestion for you is to disable the functionality of the code, like disable SPI, RTC, softdevice (don't initialize them) until you can enter sleep mode. Note that if you run the chip in debug mode it won't be able to enter sleep mode. 

Related