Pin2 interrupt on Leonardo

Hi Cannot get pin interrupt to work on pin 2 on a Leonardo. Using latest version of IDE. My research indicates this is a known issue but i have been unable to find a solution anywhere. Does anyone know how I can get a pin interrupt to work on pin 2 (I require pin 3 for something else), or failing that pin 1 or 0?

d

It’s definitely so that IDE 1.0.1 defines pin 3 as interrupt 0 and pin 2 as interrupt 1 but I cannot find any error in the code that would implicate that this shouldn’t work.

Defining pin 0 as interrupt:

EICRA = (EICRA & ~((1<<ISC20) | (1<<ISC21))) | (mode << ISC20);
EIMSK |= (1<<INT2);

Defining pin 1 as interrupt:

EICRA = (EICRA & ~((1<<ISC30) | (1<<ISC31))) | (mode << ISC30);
EIMSK |= (1<<INT3);

The interrupt routines are defined then as

SIGNAL(INT2_vect) {
  // pin 0 service routine
}

SIGNAL(INT3_vect) {
  // pin 1 service routine
}

You could use the same type of code to try to activate pin 2:

EICRA = (EICRA & ~((1<<ISC10) | (1<<ISC11))) | (mode << ISC10);
EIMSK |= (1<<INT1);

SIGNAL(INT1_vect) {
  // pin 2 service routine
}

Please keep in mind that you cannot use the I2C interface (Wire library) while using the pins 2 and 3 (these pins are multiplexed to SDA and SCL). On pins 0 and 1 is the Serial1 on the Leonardo, so you cannot use that object if you use the pins for interrupts.

dc509: Hi Cannot get pin interrupt to work on pin 2 on a Leonardo. Using latest version of IDE. My research indicates this is a known issue but i have been unable to find a solution anywhere. Does anyone know how I can get a pin interrupt to work on pin 2 (I require pin 3 for something else), or failing that pin 1 or 0?

d

Take a look at this http://arduino.cc/forum/index.php/topic,124057.0.html