Aha! See this link:
http://propaneandelectrons.com/blog/int … atmega32u4
INT6 on Arduino Leonardo / ATMega32U4
Mar 19 2013
The documentation for Arduino’s attachInterrupt function lists the pins for the four interrupts available on an Arduino Leonardo. But the Leonardo uses the ATMega32U4, which has a fifth external interrupt (called external interrupt 6, or INT6, just to be confusing). INT6 is not available from the attachInterrupt() function, but is available if you access it directly via the registers EICRB (External Interrupt Control Register B) and EIMSK (External Interrupt Mask Register):
EICRB |= (1<<ISC60)|(1<<ISC61); // sets the interrupt type
EIMSK |= (1<<INT6); // activates the interrupt
For more information, see sections 11.0.2 and 11.0.3 of the ATMega32U4 datasheet.
To set the interrupt function, define it in the normal AVR way:
ISR(INT6_vect) {
// interrupt code goes here
}
The interrupt type is described in Table 11-3 of the datasheet, and is similar to interrupts 0 - 3:
ISC61 ISC60 Triggered By
0 0 INT6 low
0 1 Any logical change on INT6
1 0 Falling edge between two INT6 samples
1 1 Rising edge between two INT6 samples
For INT6 to work, it requires the AVR I/O clock to be present, unlike INT0 - INT3.
INT6 uses Port E Pin 6 (PE6), which corresponds to Digital Pin 7 on the Leonardo.
I tried this, and the external interrupt on pin 7 works. I summarized this in a sample code below:
void setup(){
EICRB |= (1<<ISC60)|(0<<ISC61); // sets the interrupt type for EICRB (INT6).
// EICRA sets interrupt type for INT0...3
/*
ISCn0 ISCn1 Where n is the interrupt. 0 for 0, etc
0 0 Triggers on low level
1 0 Triggers on edge
0 1 Triggers on falling edge
1 1 Triggers on rising edge
*/
EIMSK |= (1<<INT6); // activates the interrupt. 6 for 6, etc
}
void loop(){
//do other things here
}
ISR(INT6_vect) {
// interrupt code goes here
}
It would be great if they included this in the IDR, but for now I’ll post links in the product description and the arduino forum. There are also 8 pin change interrupts (which is really all I need, but this will work too), which is described in chapter 11 of the datasheet (all 4 pages of it). There aren’t any examples, but I’m sure a google search would reveal one. I would assume it’s similar to this.