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

Unknown interrupt wakes chip immediately after calling sd_app_evt_wait()

Hi Nordic team,

I'm struggling with an issue where my chip wakes immediately after calling sd_app_evt_wait() - specifically if I call app_timer_start() before the wait for event command.

I'd had this issue for a while which I managed by calling  sd_app_evt_wait() twice in succession - but getting toward the end of my development I'm seeing in some edge use cases this 2x call causes issues.

For reference I'm using an nrf52832 on the nrf52DK - with Softdevice 7.2.0 & SDK 17.0.2.

A simplified version of my code to highlight the issue looks like this:

//main Loop function
while (true){
    printf("Sleep\n");
    
    app_timer_stop(rtc_wake);                                //Stop any running wake timers
    app_timer_start(rtc_wake, APP_TIMER_TICKS(10000), NULL); //Start timer for 10s
    sd_app_evt_wait();                                       //Go to sleep
}      

Ideally the system should wake via app_timer interrupt every 10s and print "Sleep". However I'm seeing it wake immediately and repeatedly print over and over. I've tried checking for and clearing all IRQs for pending interrupts via a for loop before sleep & added code to clear the FPU errata interrupt before sleep, but none of these work.

I've possibly narrowed down the cause to the app_timer_start() - which when successfully started triggers an interrupt which immediately wakes - the loop runs again with app_timer being stopped and successfully started which repeats the process.

This is highlighted even more If I remove the app_timer_stop() - the system wakes once after the 1st app_timer_start() then the next loop's app_timer_start() call is ignored as it's already running & the system sleeps for 10s. However in my full code I'll need to stop any timers before calling so this isn't a solution. 

Could you please advise how to correct to this behaviour.

Many Thanks,

K

Related