Arduino Micro interrputs

I just purchased a genuine Arduino Micro board and I am trying to figure out what pins are have interrupts . I have found several diagrams that give me different answers. The attached diagram says the RX and TX are pins 20 & 21 and interrupts 2 & 3 but when I try and use this in my code the information I get is incorrect. I have found other diagrams that say Rx & TX are pins 1 & 0 .

I used pins 2 & 3 on an Arduino Mega and everything worked fine.

Can anyone please tell me what I am reading wrong

all pins has the possibility
http://ww1.microchip.com/downloads/en/devicedoc/atmel-7766-8-bit-avr-atmega16u4-32u4_datasheet.pdf

Pins 20/21 refers to pin numbers on the chip itself

I got this pin map...

from this page.

All you can want on AVR interrupts, applies to all.

You can run Pin Change interrupts on the PCINT pins, maybe all IO pin, and edge-trigger interrupts in the INT pins, 0, 1, 2, and 3.

The Micro uses the same pinout as the Leonardo. If you look in pins_arduino.h for the Leonardo you will see the macro that maps pin number to interrupt number:

#define digitalPinToInterrupt(p) 
((p) == 0 ? 2 : 
((p) == 1 ? 3 : 
((p) == 2 ? 1 : 
((p) == 3 ? 0 : 
((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))

Pins 0, 1, 2, 3, and 7 have external interrupts 2, 3, 1, 0, and 4 respectively. Note that Pin 2 and Pin 3 have 0 and 1 on the UNO but 1 and 0 on the Leonardo/Micro. Best to use the macro.

johnwasser:
The Micro uses the same pinout as the Leonardo. If you look in pins_arduino.h for the Leonardo you will see the macro that maps pin number to interrupt number:

#define digitalPinToInterrupt(p) 

((p) == 0 ? 2 :
((p) == 1 ? 3 :
((p) == 2 ? 1 :
((p) == 3 ? 0 :
((p) == 7 ? 4 : NOT_AN_INTERRUPT)))))



Pins 0, 1, 2, 3, and 7 have external interrupts 2, 3, 1, 0, and 4 respectively. Note that Pin 2 and Pin 3 have 0 and 1 on the UNO but 1 and 0 on the Leonardo/Micro. Best to use the macro.

Thank you. I switched to pins 0 & 1 and used inter 2 and now it works. My diagram had pin 7 as inter 6 and that still didn't work even when I switched it to inter 4.

I think the ultimate reference is a combination of the datasheet and the schematic.

atmos:
I switched to pins 0 & 1 and used inter 2

Don't hardcode inerrupt 2, use the digitalPinToInterrupt macro for portability and abstraction.

const uint8_t pin = 0;
attachInterrupt(digitalPinToInterrupt(pin), isr, mode);

Pieter