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

SDK 14.0.0 -> 14.2.0 migration: app_timer_create() thinks the timer is already running.

In migrating an existing application from SDK 14.0.0 to SDK 14.2.0, I am finding that the first timer I create gets NRF_ERROR_INVALID_STATE on calling app_timer_create(). This is not because the module isn't initlisalised, it's because app_timer_create() thinks the timer is already running. I am quite sure it's not - I've stepped through the code from the top of main and this is the first time this timer ID is used in the code.

I'm hitting this:

if (((timer_node_t*)*p_timer_id)->is_running)
{
  return NRF_ERROR_INVALID_STATE;
}
The timer is defined using:
APP_TIMER_DEF(m_acc_int_lag_timer_id);
and created using:
err_code = app_timer_create(&m_acc_int_lag_timer_id, APP_TIMER_MODE_SINGLE_SHOT, acc_on_int_lag_timeout);
APP_ERROR_CHECK(err_code);
Looking for m_acc_int_lag_timer in my .map file, I see:
.rodata.m_acc_int_lag_timer_id
0x0000000000048a68 0x4 _build/app/acc_bma250e.c.o
and:
.rodata.m_acc_int_lag_timer_id
0x0000000000048a68 0x4 _build/app/acc_bma250e.c.o
I see nothing in the release notes for SDK 14.1.0 or 14.2.0 that would explain this.

Related