We have been using gpiote low_accuracy port events on battery powered devices for years without any issues, but now we bumped into a strange issue.
Details: 8 PORT (hi_accuracy = false) interrupts are enabled. 5 of them are connected to ext radio chip (in NRF_GPIOTE_POLARITY_LOTOHI configuration) and 3 of them are some buttons with large debounce capacitors and with external pullups driven by other gpio pins, in NRF_GPIOTE_POLARITY_TOGGLE mode. Only sdk api functions are used. Using nrf52832 QFAAE0, SDK 15.3, Segger Embedded Studio 4.22, OSX 10.14.4, custom board with crystals and DCDC.
Problem: No port interrupts coming (port interrupt lockup). No port irq's are coming in after device shutdown and gpio button wakeup (after some hard_to_reproduce combination of pin initialization and transitions). nrfx_gpiote_irq_handler() is never called after this, even though pin input states are changing properly when reading with nrf_gpio_pin_read().
Reason: DETECT signal in GPIO module is constantly high - there cant be another rising edge to call nrfx_gpiote_irq_handler(). Thus there is no mechanism to change the reason of DETECT signal (inverting relevant PINx.CNF.SENSE states in nrfx_gpiote_irq_handler()).
Proof: after resetting LATCH register by calling NRF_P0->LATCH = 0xFFFFFFFF, the register is not fully cleared (the datasheet states that LATCH register is not cleared if PINx.DETECT is high). LATCH register readout (after resetting it) changes when pushing the buttons (relevant bits are cleared and come back when button is released). Note: LATCH is only used as a probe to prove the reason of problem, I'm not using LDETECT.
To reproduce the problem, device has to be put to sys-off (deinit leaves main button port event initialised for wakeup), then after wakeup caused by the button (when in debug build) or nfc (in release build) the LATCH register has bits on after clearing and port irqs are not coming in. I dont remember ever seeing such lockup state occure during runtime, only now during startup. This strange behavior is very fragile - almost any change to anything (and sometimes no change at all) hides the problem, so its very hard to reproduce the problem on DK.
Assumption: It seems that it has to do with timings or something, because release and debug builds behavior differs slightly. It might be that in nrfx_gpiote_in_event_enable() the pin state is read, then a transition happens on that same pin and then nrf_gpio_cfg_sense_set() applies an outdated state. It seems to me that SDK does nothing to handle the unlikely state change that can happen in timewindow between reading the pin state and setting sense polarity (PINx.CNF.SENSE). Maybe my assumptions are wrong, but I dont dare to ship devices with this...