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

Calling app_timer_start()

Hi,

I found this in the documentation for the Timer Library of the SDK 14.

'When app_timer_start() or app_timer_stop() are called, the timer operation is only queued, not executed. A software interrupt is triggered and the actual timer start/stop operation is executed by the SWI0 interrupt handler. If the application code that calls the timer function is running at the same or higher interrupt priority level, the timer operation will not be performed until the application handler has returned.'

I am not quite sure what does it mean. What happens when I call app_timer_start()? Can anybody please explain this?

Thanks

  • Hi,

    The app_timer API is interrupt driver, using software interrupts (SWI), which in principle is exactly the same as "normal" HW interrupts. There are two main cases:

    • app_timer_* called from main context (or interrupt priority lower than for SWI0). Interrupt is triggered, and the timer operation is processed immediately before continuing with the main thread.
    • app_timer_* called from interrupt context of same or higher priority as the SWI0 used by the apptimer. In that case the interrupt is triggered, but the existing interrupt routine (and any other with higher priority) will finish before the app_timer interrupt routine is run.

    (This explanation ignores that interrupts can occur after the app_timer API call and before it is processed.)

Related