Arduino Atmega2560, using unmapped pins? (Interrupts)

Hello all,

I have been using the mappings provided here: Arduino mega, using pins that are not mapped. - Suggestions for the Arduino Project - Arduino Forum

In order to make full use of the chip, and the map seems to be working fine for basic read/write functionality. But I am trying to get interrupts working on the extra pins.

I added:

#define digitalPinToInterrupt(p) (p == 2 ? 0\
                               : (p == 3 ? 1\
                               : (p == 18 ? 5\
                               : (p == 19 ? 4\
                               : (p == 20 ? 3\
                               : (p == 21 ? 2\
                               : (P == 81 ? 6\
                               : (p == 82 ? 7\
                               : NOT_AN_INTERRUPT))))))))

I also used the following code to initialize the newly mapped pin 82:

  pinMode(82, INPUT);           // set pin to input
  digitalWrite(82, HIGH);       // turn on pullup resistors

  attachInterrupt(82, blink, FALLING);

but my function blink never gets called if I am using any of the new pins.

Any ideas?

Thanks!

You might take a look at the MegaCore AVR Pinout variant file to see if that gives you a clue:

You might actually try using MegaCore to check if that will get things to a working state. Just note that the pin mapping for the AVR Pinout is different from the Arduino Mega pinout (see GitHub - MCUdude/MegaCore: Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128)

I am not sure why mine wasn't working, but I installed that one and now it is working at least while the chip isnt in sleep mode(After changing pin numbers for the AVR core version)

Now it just won't wake from sleep from pin 9(7 on the AVR core)

thanks a lot!