Currently, I'm using the following:
if((err_code = app_timer_stop(m_timer_id)) == NRF_SUCCESS)
{
err_code = app_timer_start(m_timer_id, APP_TIMER_TICKS(g_timer_val*1000, APP_TIMER_PRESCALER), NULL);
APP_ERROR_CHECK(err_code);
}
else
{
APP_ERROR_CHECK(err_code);
}
The problem is that most of the time, the above code is called from various handlers and ISRs which have a higher priority than SWI0 (which is used to update the timer task list). So the timer list update actually occurs after the ISR calling the above code returns.
Due to all this, the new timer value doesn't actually get loaded into the timer. I'm pretty sure this is because the stop timer action doesn't get performed.
In short, does anyone have any ideas on how a app timer value can be updated while it is running?
Thanks.