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

Maximum expected interrupt delay when using Softdevice

I am trying to create an 80ms pulse by setting a GPIO high, starting an application timer with 80ms timeout and then setting the GPIO low in the timer ISR. I am aware that it is a common problem when trying to time accurately with the Softdevice also running. From looking at the Softdevice documentation, the worst case ISR delay (assuming no flash writing is going on) is a few us.

However when I look at the pulses on a scope, I see that they fluctuate in period from 80ms to around 130ms. So I am seeing a worst case ISR delay of 50ms. Is that to be expected?

I have set:

#define APP_TIMER_CONFIG_IRQ_PRIORITY 2

so only the highest priority Softdevice interrupts should pre-empt my timer's ISR.

I don't need very accurate timing: a period range of 80ms to 110ms would be perfectly fine. Is there a way to achieve that? My feeling is that moving to a h/w timer wouldn't change matters because it wouldn't allow a higher ISR priority. I need to send a specific number of pulses and have a mark/space ratio of roughly 80:1, so I'm not sure that I can do it with a PWM.

n.b. If I disable the softdevice then the period is exactly 80ms every time.

Related