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

Can app_timer_cnt_get be interrupted by SD?

As the title says, can the call app_timer_cnt_get() be interrupted by the SoftDevice and return an outdated value?

Parents
  • Anything which takes longer than one instruction can get interrupted by anything with a higher interrupt priority, so not only could app_timer_cnt_get() be interrupted after it reads the count and before it returns it, the code it returns to could get interrupted before it processes the value (which is much more likely as when optimised reading the counter is one single instruction).

    You should basically assume that between any two instructions anywhere in your code there could be an indeterminate gap caused by an interrupt, softdevice or other.

  • I see. But this method is still the most exact way to measure elapsed time, correct? Perhaps using the one-line expression instead of the function call could reduce the delay. This would be used in an application with a configured connection interval of around 10ms, so plenty of SD interrupts I believe...

Reply Children
No Data
Related