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

should i timers_init(); ?

hi this is my timers_init(); func

static void timers_init(void)
{
    uint32_t err_code;

    // Initialize timer module.
    APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false);

    
}

when i dont init it the ble crash and says in this line of code there is error

static void conn_params_init(void)
{
    uint32_t               err_code;
    ble_conn_params_init_t cp_init;

    memset(&cp_init, 0, sizeof(cp_init));

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_CONN_PARAMS_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_CONN_PARAMS_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_CONN_PARAMS_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = m_hrs.hrm_handles.cccd_handle;
    cp_init.disconnect_on_fail             = false;
    cp_init.evt_handler                    = on_conn_params_evt;
    cp_init.error_handler                  = conn_params_error_handler;

    err_code = ble_conn_params_init(&cp_init);
    APP_ERROR_CHECK(err_code);
}

when i init timer i check the rtc handler by this

void RTC1_IRQHandler(void) 
{
	
	i[15]++;
}

it triger alot something like 20000 in sec

why i should init the timer?

  • If you are using the SDK examples, then you should init the APP_TIMER because they are used by

    • BSP (board support package)
    • to blink leds periodically
    • also used in ble_conn_params to check if we have reached maximum attempts and needs to change the conn params. (please look into ble_conn_params.c->ble_conn_params_init). Also check how the single shot timer is configured to fire update_timeout_handler.

    So the answer is you should init timer because other parts of your code is using it. Using non initialized drivers will cause problems.

Related