Pro Micro Interrupt problems

I have been having the same issues described in this thread. Only external interrupts 0 and 1 seem to work. Unfortunately these are associated with pins 2 and 3, and I need those for i2c.

Does anyone know of a reliable fix for the IDE to support the No. 2, 3 and 4 interrupts on Leonardo (nearest thing to Pro Micro) as described here?

I want to minimise power consumption in a battery powered circuit by putting the Micro Pro into a low power sleep mode, and waking it only on events from 2 pushbuttons and the 1Hz square-wave output from an RTC.

My current solution uses the Sleep_n0m1library, sleeping for 50ms periods and polling the inputs between sleeps.

Thanks,

Paul

Paul,

This should explain: http://rcarduino.blogspot.com/2013/04/the-problem-and-solutions-with-arduino.html

While the Leonardo appears to have 4 external interrupts, int2 and int3 are attached to digital pins 0 and 1 which are almost always reserved for serial input/output. So yes there are four interrupts, but two of them are only available by disabling serial functionality.

mrburnette: This should explain:..."While the Leonardo appears to have 4 external interrupts, int2 and int3 are attached to digital pins 0 and 1 which are almost always reserved for serial input/output...two of them are only available by disabling serial functionality."

Thanks Ray. In my circuit, I am not using those pins for serial input/output, yet I still cannot use them for interrupts! The link does not explain how to disable the serial functionality. Those pins are associated with "Serial1" ("Serial" being the comms to PC via USB), but my sketch is not doing a Serial1.begin() or anything else with "Serial1".

I read somewhere in that thread I posted that there is a problem with the Arduino IDE that prevents them from working, even though the 32U4 has that capability. My sketch, which attaches interrupts to int2 and int3, compiles and uploads fine, but the interrupt routines don't get called. I know the pin changes are occurring as expected, because my code currently polls those pins for changes and that works fine.

If I attach interrupts to int0 and int1, that code gets executed each time my sketch accesses the i2c bus. Unfortunately the i2c interface can't be moved to other pins on the 32U4.

Maybe I will look into that pin change interrupt library.

Hi PaulRB, Sorry to ask for informations about this old thread, but i'm stuck in the same way as you. Lot of time trying things, and searching on the web either.

I'm using a 32U4 controler, and unable to make working the external interrupt INT0, INT1 (pin SCL and SCA). (same thing for INT2 and INT3, wich are initially RX TX, no success. But i'm interrested specially on INT0 and INT1).

Did you finally succes to do this? If not, what solution have you implemented to use external interrupts on this chip?

If anyone have any help on the way to follow, it will help a lot.

Thanks!

Fuji,

I've just obtained the Pro Micro board, so haven't done much with it yet. Per the SparkFun Hookup Guide web page,

The Pro Micro has five external interrupts, which allow you to instantly trigger a function when a pin goes either high or low (or both). If you attach an interrupt to an interrupt-enabled pin, you’ll need to know the specific interrupt that pin triggers: pin 3 maps to interrupt 0, pin 2 is interrupt 1, pin 0 is interrupt 2, pin 1 is interrupt 3, and pin 7 is interrupt 4.

So, the Uno only has 2 external interrupts (INT0, INT1) on digital pins 2 & 3, where as the Pro Micro, according to SparkFun, has 5 external interrupts (INT0, INT1, INT2, INT3, INT6) on digital pins 3, 2, 0, 1, 7 respectively. Pin mapping on the Arduino Leonardo board (also 32U4 processor) has the same pin order.

For readibility sake, you would likely want to use the function DigitalPinToInterrupt(pin) inside the attachInterrupt() declaration statement. Like this:

attachInterrupt(digitalPinToInterrupt(3), blink, CHANGE); // INT0 interrupt

Hope that helps.

Could you use PCINTs, as a last resort if you can't get this sorted out?

@borland: Yes you're right, i've already read the docs and already tried many syntaxes, including those that you suggest, neither worked.

@DrAzzy: Found this option on the web, but 32U4 is capable of external interrupt so i wanted to make it work.

Finally i studied the 32U4 doc and used directly the registers to config the ext interrupts, and it seems to work fine. (Registers: EIMSK, EICRA, EIFR.... )

Maybe there's an issue with 32U4 in the convenience function "attachInterrupt()". Or compilation problem with I2C, wich start this module while we don't need it. No time to look at this.

Glad you got it working.

Since those registers are R/W, did you try reading the register bits to see what was not being set from the Arduino attachInterrupt() function?

Maybe for 32U4, it is setting the mode bits in the External Interrupt Control Registers A or B (EICRA or EICRB), but not enabling the interrupt in the External Interrupt Mask Register (EIMSK).

EICRA &= ~(bit(ISC00) | bit (ISC01));  // clear existing flags
EICRA |= bit (ISC01);    // set wanted flags (falling level interrupt)
EIMSK |= bit (INT0);     // enable it

Interrupts was enabled using attachInterrupt(), because my isr function was started. But started many times and regularly, without any external operation on the pin. Like it was the I2C clock who was triggering it.