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

Timer1 firing more frequently in ble_app_beacon example SDK16

Hi, i am using timer by help of timer example from the SDK16. There they used timer0 and i tested the results were 100% perfect but when i add the same part and resolve compiler issues, then i started testing it was throwing fatal error with ble_app_beacon example. Basically whenever the timer fired i am doing advertisement and when advertisement starts by calling sd_ble_gap_adv_set_configure() gives fatal error and system reset. Then i felt soft device might be using timer0 so i changed to timer1 configuration by modifying sdk_config.h, here the issue is timer firing more frequently than its normal speed. The time i set was 500 ms which was same as timer example present in SDK. 

What could be the issue? Do i need to change any frequency component to get an exact time? I attached sdk_config.h and code snippet so please have a look at it.

Thank in advance.

const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(1);
static void timer_run()
{
    uint32_t time_ms = 500; //Time(in miliseconds) between consecutive compare events.
    uint32_t time_ticks;
    uint32_t err_code = NRF_SUCCESS;
    nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG;
    err_code = nrf_drv_timer_init(&TIMER_LED, &timer_cfg, adv_timer_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_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    nrf_drv_timer_enable(&TIMER_LED);
    }
sdk_config.h

Parents Reply Children
Related