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

nRF52 GPIOTE interrupt latency

Hi 

I have a problem with long latency on interrupts and long delay on retriggered interrupt.

I have a nRF52832 running with external HFCLK source. Using the SDK 14.2.0. The softdevice is disabled before using the GOIOTE and re-enabled afterwards.

The GPIOTE is setup like this:

Fullscreen
1
2
3
4
5
6
7
8
if (!nrf_drv_gpiote_is_init())
{
err_code = nrf_drv_gpiote_init();
APP_ERROR_CHECK(err_code);
}
nrf_drv_gpiote_in_config_t config = GPIOTE_CONFIG_IN_SENSE_HITOLO(true);
nrf_drv_gpiote_in_init(RFID_PIN_DOUT, &config, gpiote_void_handler);
nrf_drv_gpiote_in_event_enable(RFID_PIN_DOUT, true);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

As you can see I have skipped the original interrupt service routine from the SDK and wrote my own to avoid the overhead.

My interrupt service routine is like this:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
void GPIOTE_IRQHandler(void) // DOUT call back handler
{
// Clear the GPIO event
NRF_GPIOTE->EVENTS_IN[0] = 0;
// Mark start of interrrupt
NRF_P0->OUTSET = 1 << RFID_PIN_TEST1;
/* Interrupt code here. Takes around 2µs */
// Mark end of interrrupt
NRF_P0->OUTCLR = 1 << RFID_PIN_TEST1;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I got a latency of 1.6 µs from the falling edge on GPIO pin RFID_PIN_DOUT to the rising edge of RFID_PIN_TEST1.

An if an additional falling edge occurs before the interrupt service routine, there is a delay between the falling edge of RFID_PIN_TEST1 to the next rising edge also on 1.6 µs.

I had expected much lower latency on a 64MHz processor. It should take around 16 clock cycles to enter or leave the interrupt service routine, which is 0.25µs. 

The big question: What does the MCU do en the rest of the time?