How to avoid going back to sleep after waking up from Timer interrupt?

Hi 

I am using nrRF52832 S132, I have a timer interrupt which wakes up the processor from sleep periodically. 

In that timeout interrupt even handler, I queue and event which I wish to be executed from main loop using the scheduler (I don't want to execute too much code from the interrupt)

My problem is that after waking and queuing the event, the processor just goes back to sleep, it handles the interrupt only after the next cyclic wake-up. 

For example, the timeout interrupt occurs each 1sec, but the scheduler only calls the event each 2sec. 

I also tried to implement the same concept without the scheduler (using a simple flag set by the timer interrupt and checked in the main loop)

Why would something like that happen? Is there a way to prevent the processor from going back to sleep until I allow it again? 

Thanks! 

Parents
  • Hello,

    This is one of those issues I would expect to occur infrequently, in other words it may sometimes happen if the interrupt event handler is called right before the while-loop in main want to go to idle (sleep), but if it happens continously I would likely have looked at your while-loop and compared it with the ble peripheral examples. Edit: Maybe even consider a 1us delay on wakeup from idle in main() before checking flags etc and going back to idle.

    Kenneth

  • Hi Kenneth

    I further investigate and compared, the problem seems to be me calling the function - sd_app_evt_wait();

    I removed it and now it works. I also checked my sleep current consumption and it seems to be as low as before

    So I am not sure why I place the sd_app_evt_wait() there in the first place, nor do I know why would it cause the issue I described.

    Thanks!

Reply
  • Hi Kenneth

    I further investigate and compared, the problem seems to be me calling the function - sd_app_evt_wait();

    I removed it and now it works. I also checked my sleep current consumption and it seems to be as low as before

    So I am not sure why I place the sd_app_evt_wait() there in the first place, nor do I know why would it cause the issue I described.

    Thanks!

Children
Related