Hello All,
I am using an alternative board: 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 Essentially the problem I am having is my interrupts are not working to wake an atmega2560 from sleep using the AVR core pinout, here is my test code:
#define alarm_pin 4
volatile int alarm_flag = 0;
void blink()
{
noSleep(); //comment out for no-sleep example
alarm_flag = 1;
Serial.println("Alarm?");
}
void setup()
{
Serial.begin(250000);
Serial.println("Start");
pinMode(alarm_pin, INPUT); // set pin to input
digitalWrite(alarm_pin, HIGH); // turn on pullup resistors
}
void clr_alarm()
{
detachInterrupt(alarm_pin);
Serial.print("blink!\r\n");
delay(1000);
alarm_flag = 0;
attachInterrupt(alarm_pin, blink, FALLING);
}
void loop()
{
Serial.println("Loop");
sleepMode(SLEEP_POWER_DOWN); //comment out for no-sleep example
attachInterrupt(alarm_pin, blink, FALLING);
Serial.flush(); //comment out for no-sleep example
sleep(); //comment out for no-sleep example
noSleep(); //comment out for no-sleep example
delay(1000);
if (alarm_flag == 1) {
clr_alarm();
}
}
The interrupt works if I remove the sleep lines, but won't wake the micro from sleep. I've tried interrupts INT4 and INT7, the board I am currently working on does not have any other INT pins broken out.
Thanks!