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

App_timer stops working

I have a timer that is coming every 100ms. I use it as a system clock to time and manage events. The main function has a loop that calls sd_app_evt_wait() When woken up by the interrupt it reads an accelerometer through i2c.

It works for a while and then it stops working. What would cause the timer to stop working? I even changed the code to stop the timer, do the accelerometer read and then start the timer again and it still gets to a point where the timer stops firing.

//setting up timer APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

err_code = app_timer_create(&m_timer_systemTick_id,APP_TIMER_MODE_REPEATED,systemTick);

//command to start timer app_timer_start(m_timer_systemTick_id,APP_TIMER_TICKS(100,APP_TIMER_PRESCALER),NULL);

Parents
  • How the scheduler works isn't entirely clear in the documentation. I'll try my best to explain. With all MCU's there is the main loop and there are interrupts. Interrupts can be trigger from various sources, and depending on the source will have different priority for execution. Also as you know an interrupt is a blocking operation, blocking whatever code was executing, to run the ISR.

    The scheduler allows your application to issue an event using app_sched_event_put. What this does is in the main loop if there are not Interrupts being handled and the system is idle it will execute any scheduler events via app_sched_execute(). If there any multiple pending scheduler events, they are processes in the order they are received (FIFO).

Reply
  • How the scheduler works isn't entirely clear in the documentation. I'll try my best to explain. With all MCU's there is the main loop and there are interrupts. Interrupts can be trigger from various sources, and depending on the source will have different priority for execution. Also as you know an interrupt is a blocking operation, blocking whatever code was executing, to run the ISR.

    The scheduler allows your application to issue an event using app_sched_event_put. What this does is in the main loop if there are not Interrupts being handled and the system is idle it will execute any scheduler events via app_sched_execute(). If there any multiple pending scheduler events, they are processes in the order they are received (FIFO).

Children
No Data
Related