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
  • Again a scheduler event is issued via app_sched_event_put:

    app_sched_event_put(void * p_event_data, uint16_t event_size, app_sched_event_handler_t handler)

    The handler parameter passed is a function, whose code is run when this event is executed.

    The nice thing about using the scheduler with app_timers is that the app timeout handler is automatically used as the event handler. So if you initialize your APP_TIMER as using the scheduler, the timeout handler function will be handled as mentioned above. This is the safest order of execute for app_timers.

    I am using SDK 6.1, as Aryan mentioned SDK 8.0 sets up the app_timers and scheduler slightly differently but the general concept of usage and execution is pretty much the same.

Reply
  • Again a scheduler event is issued via app_sched_event_put:

    app_sched_event_put(void * p_event_data, uint16_t event_size, app_sched_event_handler_t handler)

    The handler parameter passed is a function, whose code is run when this event is executed.

    The nice thing about using the scheduler with app_timers is that the app timeout handler is automatically used as the event handler. So if you initialize your APP_TIMER as using the scheduler, the timeout handler function will be handled as mentioned above. This is the safest order of execute for app_timers.

    I am using SDK 6.1, as Aryan mentioned SDK 8.0 sets up the app_timers and scheduler slightly differently but the general concept of usage and execution is pretty much the same.

Children
No Data
Related