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

Hardware timer stopped or not short cleared during interrupt

Hi There, I'm having problems with my hardware timer appearing to stop counting or not being cleared via a short when the timer interrupt is executing.

In my application, I have the following:

  • Hardware TimerCounterA, configured to generate a compare event every 100uS. A short is configured in that timer to clear the timer when the compare event fires.
  • Hardware TimerCounterB, configured in count mode, a PPI channel is used to connect the compare event on TimerCounterA to the count task on TimerCounterB.
  • GPIOTE pin toggle, a pin is configured to be toggled via the fork option of the PPI channel which connects TimerCounterA and TimerCounterB

I am monitoring the toggled pin using an oscilloscope, and can see that when interrupts are enabled for TimerCounterA, there is an extra delay in the pin toggle of about 0.8uS. If I disabled this interrupt, then time between toggles of the pin is an accurate 100.0 uS.

I have a timers & GPIOTE configured as follows:

tTimerAConfig.frequency = NRF_TIMER_FREQ_16MHz;
tTimerAConfig.mode      = NRF_TIMER_MODE_TIMER;
tTimerAConfig.bit_width = NRF_TIMER_BIT_WIDTH_16;
tTimerAConfig.p_context = NULL;
tTimerAConfig.interrupt_priority = APP_IRQ_PRIORITY_LOW;
nrf_drv_timer_extended_compare(ptNrfTimerA, NRF_TIMER_CC_CHANNEL0, 1600, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, false);
...
tTimerCounterBConfig.frequency = NRF_TIMER_FREQ_16MHz;
tTimerCounterBConfig.mode      = NRF_TIMER_MODE_COUNTER;
tTimerCounterBConfig.bit_width = NRF_TIMER_BIT_WIDTH_32;
tTimerCounterBConfig.p_context = NULL;
tTimerCounterBConfig.interrupt_priority = APP_IRQ_PRIORITY_MID;
...
// Configure the GPIO pin as an toggling output.
nrf_drv_gpiote_out_config_t config = GPIOTE_CONFIG_OUT_TASK_TOGGLE(false);
err_code = nrf_drv_gpiote_out_init(TEST_CLOCK_OUTPUT_PIN, &config);
APP_ERROR_CHECK(err_code);

// Now configure the PPI, we are going to use the the available fork mechanism (enables call of 2nd task from a single event).
err_code = nrf_drv_ppi_channel_fork_assign(tPpiChannel, nrf_drv_gpiote_out_task_addr_get(TEST_CLOCK_OUTPUT_PIN));
APP_ERROR_CHECK(err_code);

// Enable the pin for control
nrf_drv_gpiote_out_task_enable(TEST_CLOCK_OUTPUT_PIN);

The interrupt is very simple, it does a small set of calculations and then calls nrf_drv_timer_clear().

Any thoughts on why I am seeing this delay?

Cheers,

Donal

Parents Reply Children
No Data
Related