Well, I have this code that works perfectly, it uses three pins to control some Shift Registers that are for reading some buttons, and also has a midi output port using AltSoftserial, the thing is that I am using another Atmega328 to generate a clock signal for the Midi Port, so it can be more accurate, I'm have tried to interrupt pin 2 and 3, on Rising and Falling Edge, but the code crashes when I do so, maybe it has something to do with the Libraries I am using.
This is the code that crashes (I think), Interrupt gets Enabled, but the ISR never runs...
void SetClockMode(bool clock_mode)
{
switch(clock_mode)
{
case INTERNAL_CLOCK: detachInterrupt( digitalPinToInterrupt(3) ); break;
case EXTERNAL_CLOCK: attachInterrupt( digitalPinToInterrupt(3), CHANGE, ExtClock); break;
}
}
void ExtClock()
{
Midi.ClockMessage();
//Serial.println(0);
}
// This is the code inside the MIDI class
void ClockMessage()
{
Port.write(MIDI_CLOCK); //Port is the AltSoftserial Port
}
I have attached a Zip file containing the files the sketch uses + the libraries, sketch is divided in 9 tabs, so I cant directly upload a file, sorry for that
a_MidiControlle_main.zip (77 KB)