Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ble_uart_app with timer

Hi,

I have integrated ble_uart_app with timer example provided in "SDK 17.0.2". 

When I run the program the timer timeout immediately by calling "timer_led_event_handler" instead of waiting for 5sec. I am not sure if I am missing anything here.

const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(1);

void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
    printf("\r\n Timer End");
    nrf_gpio_pin_clear(ARDUINO_0_PIN); 
    nrf_drv_timer_disable(&TIMER_LED);
}

/**@brief Application main function.
 */
int main(void)
{
    bool erase_bonds;

    // Initialize.
    uart_init();
    log_init();
    timers_init();
    buttons_leds_init(&erase_bonds);
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();

    // Start execution.
    printf("\r\nUART started.\r\n");
    NRF_LOG_INFO("Debug logging for UART over RTT started.");
    advertising_start();

    uint32_t time_ms = 5000;
    uint32_t time_ticks;
    uint32_t err_code = NRF_SUCCESS;

    nrf_gpio_cfg_output(ARDUINO_0_PIN);    

    //Configure TIMER_LED for generating simple light effect - leds on board will invert his state one after the other.
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, timer_led_event_handler);
    APP_ERROR_CHECK(err_code);

    time_ticks = nrf_drv_timer_ms_to_ticks(&TIMER_LED, time_ms);

    nrf_drv_timer_extended_compare(
         &TIMER_LED, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);

    nrf_drv_timer_enable(&TIMER_LED);
    printf("\r\n Timer Start");
    nrf_gpio_pin_set(ARDUINO_0_PIN); 

    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
    }
}

Regards

Siva

Parents Reply Children
No Data
Related