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

application timer issue

I'm using NRF51822 with soft device version 6.0.

I'm trying to create an event which should be triggered every 24 Hours. In the current implementation in our code base, I see that we are already initializing application timer module and then creating two timer instances and starting them.

APP_TIMER_INIT(APP_TIMER_PRESCALER, 4, 4, false);
app_timer_create(&timer_id1, APP_TIMER_MODE_REPEATED, timeout_handler1);
app_timer_create(&timer_id2, APP_TIMER_MODE_REPEATED, timeout_handler2);
app_timer_start(timer_id1, TIMER1_TICK, NULL);  // 1 sec
app_timer_start(timer_id2, TIMER2_TICK, NULL);  // 50 msec

Where,

#define TIMER1_TICK APP_TIMER_TICKS(60000, 0) 

Similarly, I tried creating a third timer instance(the maximum limit is already set to '4' above) in the same fashion and associated a separate (say, timeout_handler3) timeout handler for 24Hrs, i.e.

#define TIMER3_TICK APP_TIMER_TICKS(24 * 60 * 60 * 1000, 0); // 24 hours 

But then the Bluetooth module on the nRF51822 SOC didn't seem to work at all(Seems as if the softdevice failed). Any pointers to debug and/or fix this?

Thank you.

Parents
  • Thank you for your reply. This issue lead me to find another issue of higher priority and hence I will come back to this timer related issue later. However, I've one quick question: As far as I've understood, all the application timers created in this manner(as above), will have same priority level (PRIO_LOW perhaps) and the handlers associated with each of them would run to completion, before scheduler can schedule the other application timer (Though,a higher priority level interrupt can preempt this lower priority application timer interrupt). If this is the case then it seems to be quite possible that if one handler takes more time than the timeout value of the other application timer then we will miss executing the associated timeout handler(e.g. two application timers with 1 sec (A) and 50 msec(B) timeout and handler for A took 80 msec to finish). Please confirm.

Reply
  • Thank you for your reply. This issue lead me to find another issue of higher priority and hence I will come back to this timer related issue later. However, I've one quick question: As far as I've understood, all the application timers created in this manner(as above), will have same priority level (PRIO_LOW perhaps) and the handlers associated with each of them would run to completion, before scheduler can schedule the other application timer (Though,a higher priority level interrupt can preempt this lower priority application timer interrupt). If this is the case then it seems to be quite possible that if one handler takes more time than the timeout value of the other application timer then we will miss executing the associated timeout handler(e.g. two application timers with 1 sec (A) and 50 msec(B) timeout and handler for A took 80 msec to finish). Please confirm.

Children
No Data
Related