You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On SAM:
- all pins in a port share a single interrupt pin
- the interrupt status flag for a pin is set even when it is disabled
- The actual ISR does not look at the interrupt enable flags, it just
runs the callback for every pin whos interrupt status flag is set.
This meant that if:
- an interrupt was attached and later detached,
- then the interrupt condition occured, setting the flag and
- then another (still attached) interrupt on a different pin in the
same port occured,
then the detached interrupt callback would also be called.
By masking off the Interrupts Status Register using the Interrupt Mask
Register, only actually enabled interrupt handlers are called.
The incorrect behaviour has been verified using the following test sketch:
/*
To test:
- Upload this sketch to the Arduino Due
- Open the serial monitor at 115200
- Connect a jumper wire to ground and touch the other end to pins 25 and 26, alternating between them
*/
void int25() {
Serial.println("INT25");
}
void int26() {
Serial.println("INT26");
}
void setup() {
Serial.begin(115200);
pinMode(25, INPUT_PULLUP);
pinMode(26, INPUT_PULLUP);
attachInterrupt(25, int25, CHANGE);
attachInterrupt(26, int26, CHANGE);
detachInterrupt(26);
}
void loop() { }
0 commit comments