Hi, nRF newbie here, forgive me if I'm being dim. I've searched the devzone, can't see obvious answers.
nRF52840, SDK 17.0.2, Nordic SES 5.30a, using nrfx_* drivers
I'm using one of the timers for bitbashing a bespoke serial bus, and want to re-initialise it each time I use it. I'm using nrfx_timer_init(), NRFX_TIMER_DEFAULT_CONFIG, with interrupt handler, and various compare channels set using nrfx_timer_compare().
However when called a second time, nrfx_timer_init() fails with err_code of NRFX_ERROR_INVALID_STATE, because p_cb->state != NRFX_DRV_STATE_UNINITIALIZED
Which of course it won't be, it is already initialised. Why won't nrfx_timer_init() let me re-initialise it?
If I just do nrfx_timer_clear() instead of the re-init, all runs fine, but I would be happier doing a full init to ensure it is configured for the next step.
I tried adding "if (nrfx_timer_is_enabled()) nrfx_timer_uninit();" before nrfx_timer_init(), but both those funcs have
NRFX_ASSERT(m_cb[p_instance->instance_id].state != NRFX_DRV_STATE_UNINITIALIZED);
Why are these asserts here?
This is my init code
static void init_sbus_timer(void)
{
uint32_t err_code = NRF_SUCCESS;
nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;
err_code = nrfx_timer_init(&TIMER_SBUS, &timer_cfg, timsbus_interrupt);
APP_ERROR_CHECK(err_code);
}
Many thanks