High accuracy GPIO interrupts in NCS possible?

In the old Nordic SDK we had the option of using "high accuracy" interrupts with GPIOTE by using something like NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);

Is there a similar option for NCS? I am asking because in my specific use case I measure ~160us from interrupt to handler with the old SDK and ~450us with NCS and I would like to improve that.

CONFIG_ZERO_LATENCY_IRQS is on and i configure my interrupts like this:

gpio_pin_configure_dt(&conf.gpio_irq, GPIO_INPUT);
gpio_init_callback(&gpio_cb, dw3000_hw_isr, BIT(conf.gpio_irq.pin));
gpio_add_callback(conf.gpio_irq.port, &gpio_cb);
gpio_pin_interrupt_configure_dt(&conf.gpio_irq, GPIO_INT_EDGE_RISING);

Thank you

Parents
  • Hi,

    Is there a similar option for NCS? I am asking because in my specific use case I measure ~160us from interrupt to handler with the old SDK and ~450us with NCS and I would like to improve that.

    Do you see a similar delay with a simple sample to test interrupts? Just would be interresting to see if other parts of the code will impact this.

    One option is to use nrfx drivers directly instead of the Zephyr GPIO drivers, as seen in the nrfx sample. Perhaps removing some layers of abstractions will make it go faster?

    Regards,
    Sigurd Hellesvik

  • I have done some time measurements, by simply triggering another GPIO in the ISR and measuring the time between with Joulescope. The interesting thing is that on a nrf52833dk with NCS it takes 15us from trigger to ISR and using the SDK it takes 8us from trigger to ISR if high accuracy is set and 10us when it is not set. Here's the SDK code:

    void test_isr(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
    {
    nrf_gpio_pin_set(TEST_OUT);
    nrf_delay_ms(10);
    nrf_gpio_pin_clear(TEST_OUT);
    LOG_INF("TEST_IRQ");
    }

    nrfx_err_t ret = nrfx_gpiote_init();
    if (ret != NRFX_SUCCESS && ret != NRFX_ERROR_INVALID_STATE) {
    LOG_ERR("ERR: GPIOTE init failed");
    return;
    }

    nrfx_gpiote_in_config_t config = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(true);
    nrfx_gpiote_in_init(TEST_IRQ, &config, test_isr);
    if (ret != NRFX_SUCCESS && ret != NRFX_ERROR_INVALID_STATE) {
    LOG_ERR("ERR: IRQ init failed");
    return;
    }
    nrfx_gpiote_in_event_enable(TEST_IRQ, true);

    nrf_gpio_cfg_output(TEST_OUT);
    nrf_gpio_pin_clear(TEST_OUT);

  • I also did some tests with the nrfx sample you recommended. I only modified it to use different GPIO pin numbers, so I can trigger and measure with Joulescope. Using PPI the output is very fast, but when I use only the input channel, and trigger the output GPIO from button_handler, then the time measured is also 14-15us, same like with the NCS gpio API.

Reply Children
No Data
Related