nrf52 level-triggered interrupt?

I'm using the nrf52 to connect to a CAN bus via mcp2515. This chipset features an interrupt pin that will pull low when any interrupt is triggered and will stay low until all interrupt conditions are cleared. Currently I only seem to be able to attach interrupts as "FALLING", or HiToLo, this works OK until it misses a falling edge. When the falling edge is missed the interrupt is pulled low but the ISR is never called, thus I cannot clear the interrupt conditions and once this occurs I no longer receive interrupts.

A bit of googling found a similar situation with the raspberry pi and the mcp2515 when they were using FALLING interrupts: www.friendlyarm.net/.../3113

It appears that this type of behavior requires "level-triggered" interrupt support, so that when the line is pulled low only then will an interrupt be triggered.

One other thread on this forum suggests that this type of interrupt is not possible: devzone.nordicsemi.com/.../is-level-trigger-interrupt-is-available-in-nrf52

Is there any way to achieve what im trying to do, or does this situation require a different MCU with level-trigger interrupts?

  • Hi,

    I believe there are two ways to solve this, either using PORT event or falling edge as you do today:

    1. PORT event, in that case configure the GPIO pin with sense mechanism in PIN_CNF register (this is level-triggered). You will have to check the (NRF_GPIO) LATCH register to find the pin which triggered the (NRF_GPIOTE) PORT event.

    2. Use as today the falling edge interrupt, but make sure that after enabling the interrupt you manually read the pin to check if it may already be low. If it's already low execute the callback handler directly to handle the interrupt.

    Best regards,
    Kenneth