External Interrupts

External interrupts can be used to make a voltage change on a pin cause a function to be called. Each GPIO pin can be used to detect transitions, such as when the voltage goes from LOW to HIGH, or from HIGH to LOW. This can be used to avoid checking for changes on a pin “manually” by waiting in a loop until the pin changes.

Overview

External interrupts are often used to detect when events happen outside of the Maple. These can be used to tell Maple when events happen, such as when a sensor has data ready to be read, or when a button has been pushed. When such an event happens, an interrupt is raised, and the Maple stops whatever it was doing to react to it by calling a function (called an interrupt handler) which you specify using attachInterrupt().

Every pin can generate an external interrupt, but there are some restrictions. At most 16 different external interrupts can be used at one time. Further, you can’t just pick any 16 pins to use. This is because every pin on the Maple connects to what is called an EXTI line, and only one pin per EXTI line can be used for external interrupts at a time [1].

The EXTI Line Pin Map for your board lists which pins connect to which EXTI lines:

Note

You should set the pin mode of your desired pin to an input mode (e.g. INPUT, INPUT_PULLUP, INPUT_PULLDOWN).