I use the following code to enable a timer that clears itself to loop continuously via the compare0-clear shortcut. (I then use other compares, PPI, and GPIOTE to output pulses.) The timing is very solid except occasionally (randomly about once per second on average) the cycle is long by consistently about 200us (about 10% of a cycle). What could cause this?
#define IR_SAMPLE_PERIOD_nS 2008032 const nrf_drv_timer_t IR_DRV_AND_SAMPLE_TIMER = NRF_DRV_TIMER_INSTANCE(4); ... nrf_drv_timer_config_t timer_cfg = NRF_DRV_TIMER_DEFAULT_CONFIG; APP_ERROR_CHECK(nrf_drv_timer_init(&IR_DRV_AND_SAMPLE_TIMER, &timer_cfg, timer_event_handler)); time_ticks = timer_ns_to_ticks(&IR_DRV_AND_SAMPLE_TIMER, IR_SAMPLE_PERIOD_nS); nrf_drv_timer_extended_compare( &IR_DRV_AND_SAMPLE_TIMER, NRF_TIMER_CC_CHANNEL0, time_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);