I'm making a MIDI system for a synth.
Synth MIDI out -> Arduino Serial1 IN Arduino Serial1 OUT -> Synth MIDI IN Buttons etc -> Arduino IN EXT MIDI CLOCK -> Arduino Serial2 IN -> Arduino Serial1 OUT -> Synth
My question is:
The Arduino will be getting clock messages from the external source via serial... these need to be passed on out of the arduino's serial port. How can I prioritise this? As these bytes are timekeeping they're really important to the system. If I check for these incoming bytes at the same rate as I'm checking everything else (MIDI IN from the synth, Buttons, other code etc) then this will cause delays/poor timekeeping, correct? Especially as I'll be doing things like debouncing buttons and cycling through arrays.
I need the Arduino to prioritise sending bytes received from a serial port to another serial port, regardless of what else is going on. Is this possible?
I am aware of interrupt, but I've read that this doesn't work with serial. Threading would be ideal (I think?) but I'd rather not use a library for this.
Using a Mega.
Thanks in advance. Ready to answer any Q's.