timer1-4 Inaccurate timing issue on nrf5-softdevice

1.test code

the code run separately on ble-softdevice and only timer demo .test code as follow:

const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(2);

/**
 * @brief Handler for timer events.
 */
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
    static uint32_t i;
    uint32_t led_to_invert = ((i++) % LEDS_NUMBER);

    switch (event_type)
    {
        case NRF_TIMER_EVENT_COMPARE0:
            nrf_gpio_pin_toggle(13);;
            break;

        default:
            //Do nothing.
            break;
    }
}



void init_timer(void)
{
    uint32_t time_ms = 10; //Time(in miliseconds) between consecutive compare events.
    uint32_t time_ticks;
    uint32_t err_code = NRF_SUCCESS;

    //Configure pin13 on board.
    nrf_gpio_cfg_output(13);
    
    //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_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);

    nrf_drv_timer_enable(&TIMER_LED);
 
}

2.test data

test result  as follows:

picture A,show  timer2  timing jitter test on NRF5-SDK17.1 ble-softdevice 

                                       picture A

picture B ,show  timer2  timing jitter test on NRF5-SDK17.1/examples/peripheral/timer demo

                                 picture B

3.question

Why timer2  timing jitter of ble_softdevice  is more large than  peripheral-timer demo?

thanks!

Parents Reply Children
Related