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

The 52840 timer doesn't seem to work

I started a timer on the nrf52840 and the SDK is nRF5_SDK_15.2.0_9412b96, but I haven't never receive the callback message after the time. What's the reason?The code is as follows:

void timer_clock_event_handler(nrf_timer_event_t event_type, void* p_context)
{
    switch(event_type)
    {
    case NRF_TIMER_EVENT_COMPARE0:
            idle_show_time();
            break;
    default:
            break;
    }
}

void timer_init(void)
{
uint32_t err_code = NRF_SUCCESS;
uint32_t time_ms = 1000;
uint32_t time_ticks;

nrfx_timer_config_t timer_cfg = NRFX_TIMER_DEFAULT_CONFIG;

err_code = nrfx_timer_init(&TIMER_CLOCK, &timer_cfg, timer_clock_event_handler);

APP_ERROR_CHECK(err_code);

time_ticks = nrfx_timer_ms_to_ticks(&TIMER_CLOCK, time_ms);
nrfx_timer_extended_compare(&TIMER_CLOCK, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
}

int main(void)
{
    uint8_t t = 0;

    gpio_output_voltage_setup_3v3(); 
    bsp_board_init(BSP_INIT_LEDS); 
    nrf_gpio_cfg_input(BUTTON_1,NRF_GPIO_PIN_PULLUP); 
    uart_config(); 
    LCD_Init(); 

    sys_date_time_init();

    nrf_gpio_cfg_output(LED_1);
    nrf_gpio_pin_set(LED_1); 

    POINT_COLOR=RED; 
    BACK_COLOR=GBLUE; 

    idle_show_clock_background();
    idle_show_time();

    timer_init(); 
    nrfx_timer_enable(&TIMER_CLOCK); 

}

Related