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

Can't enable timer on nRF52840 DK

The code crashes at the 3rd line (nrfx_timer.c)

void nrfx_timer_enable(nrfx_timer_t const * const p_instance)
{
    NRFX_ASSERT(m_cb[p_instance->instance_id].state == NRFX_DRV_STATE_INITIALIZED);
    nrf_timer_task_trigger(p_instance->p_reg, NRF_TIMER_TASK_START);
    m_cb[p_instance->instance_id].state = NRFX_DRV_STATE_POWERED_ON;
    NRFX_LOG_INFO("Enabled instance: %d.", p_instance->instance_id);
}

Here is my init code

static void timers_init(void)
{
    ret_code_t err_code;

    //uint32_t hesa_time_ticks = 0x0000007D; //1.6msec
    uint32_t hesa_time_ticks = nrfx_timer_us_to_ticks(&hesa_timer_instance, 1600);
    nrfx_timer_config_t hesa_timer_config = NRFX_TIMER_DEFAULT_CONFIG;
    hesa_timer_config.frequency = NRF_TIMER_FREQ_250kHz;
    hesa_timer_config.mode = NRF_TIMER_MODE_TIMER;
    hesa_timer_config.bit_width = NRF_TIMER_BIT_WIDTH_16;
    hesa_timer_config.interrupt_priority = TIMER_HESA_CONFIG_IRQ_PRIORITY;
    hesa_timer_config.p_context = NULL;
    //code taken from "timer" example
    nrfx_timer_compare(&hesa_timer_instance, NRF_TIMER_CC_CHANNEL1, hesa_time_ticks, true);
    err_code = nrfx_timer_init(&hesa_timer_instance, &hesa_timer_config, hesa_sample_timer_isr);
    APP_ERROR_CHECK(err_code);
    nrfx_timer_enable(&hesa_timer_instance);
    HESA_TIMER->TASKS_START = 1;
}

I suspect this is a config problem but I can't figure what it might be

Parents Reply Children
Related