Go Down

Topic: Arduino Micro Interrupt 6 (Read 3585 times) previous topic - next topic

jrdoner

OK, I'm posting again on the Micro, which is my first use of this chip.  I need an interrupt, and the four of them which occur on TX, RX, SDA, and SCL are already in use.  That leaves the one labeled on the Micro pinout sheet as INT4, on Micro Pin 7.  However, in all the info I can find online, that is actually INT6 of the processor. 

Apparently, the Arduino IDE does not directly support that interrupt by attachInterrupt().  So the direct register manipulation that I found is as follows.

void setup()
{
   //following code enables interrupt on pin 7 for falling edge

    EIMSK |= (0<<INT6);                        //disable interrupt 6
    EICRB |= (1<<ISC60)|(0<<ISC61);   //set up INT6 for falling edge
    EIMSK |= (1<<INT6);                       //enable INT6

}


 and also

 ISR{INT6_vect)
{
    ...interrupt code
}


However, this does not seem to execute when I push my interrupt button, and in fact, the microprocessor hangs, as though it has gone off to a nonexistent address.

Does anybody have experience with this?  Calling it INT4 didn't seem to help either.

Thanks in advance for any insight.

Peter_n

The Arduino Micro : http://www.arduino.cc/en/Main/ArduinoBoardMicro
The attachInterrupt() reference : http://www.arduino.cc/en/Reference/AttachInterrupt
Expanded view of the Micro pins : http://pighixxx.com/micropdf.pdf

The Leonardo and the Micro have both "INT.6" at Arduino digital pin 7 (ATmega32U4 PE6).
According to the datasheet, it can serve as a normal interrupt, and it has a interrupt vector, just as INT0 to INT3.

I think this should work for digital pin 7 : attachInterrupt ( 4 , ....
That didn't work ? I could test it with my Leonardo.
Perhaps your values for the registers are not correct, or not every kind of interrupt is supported.
This is the Arduino library, search for 'case 4' : https://github.com/arduino/Arduino/blob/master/hardware/arduino/avr/cores/arduino/WInterrupts.c
You can see that there is a translation. The Arduino library interrupt '4' is translated into INT6.

As an alternative,  you could try the PinChangeInterrupt library (PCINT), there are 8 of those PCINTs on other pins than the normal interrupts.
I know this library : https://github.com/GreyGnome/PinChangeInt
There seems to be a new version : https://github.com/GreyGnome/EnableInterrupt

jrdoner

Thanks, 

That's a lot of source material.  I think I've tried the attachInterrupt, both 4 and 6, but I'll pursue it further.

I think it is odd that the chip is designed with 4 of the 5 external interrupts on pins that also support the most common communication protocols.  I bought one Micro: I think I'll avoid it in the future.

westfw

Quote
EIMSK |= (0<<INT6);                        //disable interrupt 6
Note that that is wrong; ORing with zero doesn't do anything to the bit.  If you want to clear the bit, you need

Code: [Select]
  EIMSK &= ~(1<<INT6);


Paul__B

And as I always ask - why do you think you need an interrupt?
:smiley-eek:

Go Up