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

Unclear on softdevice sleeping

I need to write an application that is mostly in sleep (not OFF) mode, waking once a second or so, and occasionally discovering that it has to do things. Without the softdevice, this is easy...I set up RTC1 to interrupt once a second an in the handler I determine whether or not I'm needed. But when I link with the softdevice it tells me that RTC1_IRQHandler is multiply defined, so I assume the softdevice is using it.

I can't use the SD's power_off() function, because that goes into OFF mode. I'm aware that sd_app_evt_wait() is supposed to sleep until some SD function is needed, but I need some way to tell the softdevice that I want it to turn everything off except the timer. No radio or BLE stack, just run the single once-a-second timer that may at some point call you to turn things back on. So what's the function to do that? Is that what softdevice_handler_sd_disable() does? Or does it turn off the timers as well? How do I tell the softdevice "turn off everything, except one timer, which might tell you to turn things back on later"?

Parents
  • Your assumption that RTC1_IRQHandler is being used by the softdevice when you 'link' with it, is incorrect. You don't really link with the softdevice anyway, you just call into it. So if there's an RTC1 handler it's because you have an RTC1 handler in the application code you have built.

    Most likely that's because you've included something which uses Nordic's app_timer module which in turn uses RTC1. Most of Nordic's sample code uses app_timer somewhere, the board support module uses it for button debouncing, the advertising module uses it to change advertising states, so if you have any of the boiler plate code you've built app_timer and it's using RTC1.

    Which means all you have to do to get your timer is use an app_timer of your own. Since app_timer itself has nothing at all to do with the softdevice, you can turn the softdevice on and off as much as you like, the timers will continue to work, they are an independent module.

  • Yes, I'm aware that it's actually app_timer that's using the IRQ, and I am using app_timer and app_scheduler. These seem to be not entirely decoupled from the softdevice; for example, initializing them and starting the timers, then going to sleep with __WFE() doesn't work--the IRQ is never called. The only way to sleep while waiting for events is sd_app_evt_wait(), but this returns a "softdevice not enabled" error unless the SD is initialized. So, yes, I'll have to either re-invent timer and scheduler from scratch, or else find a way to turn off most of the SD while keeping sd_app_evt_wait() active.

Reply
  • Yes, I'm aware that it's actually app_timer that's using the IRQ, and I am using app_timer and app_scheduler. These seem to be not entirely decoupled from the softdevice; for example, initializing them and starting the timers, then going to sleep with __WFE() doesn't work--the IRQ is never called. The only way to sleep while waiting for events is sd_app_evt_wait(), but this returns a "softdevice not enabled" error unless the SD is initialized. So, yes, I'll have to either re-invent timer and scheduler from scratch, or else find a way to turn off most of the SD while keeping sd_app_evt_wait() active.

Children
No Data
Related