I’m working on the MIDI side of my prototype now. I have built an H11L1-based circuit to receive MIDI and send it to the UART RX port on the Seed. Schematic:
On the left, pin 4 hits the 220 resistor and 5 goes to the diode’s cathode and then on to pin 2 on the H11. The schematic calls for 3V from the digital pin on the Seed but I am actually connected to the 3V analog pin (a mistake I haven’t corrected yet.)
I am sending data from an old but working AdrenaLinn pedal into this circuit, tried some other MIDI clock sources too.
What I’m seeing is really messy, bad MIDI data. The Seed is receiving the stream of clock pulses but also decoding random starts and stops, and if I take off the SystemRealTime type filter, all kinds of other messages too. Tracked tempo is kind of proportional to what I’m sending in, but never matches and varies a lot.
This all feels like a hardware problem to me? In case not, some code. Simplified here for space but in my test build I’m also calculating BPM and logging that periodically, and I’ve tried running a PrintLn on every message received to see what’s flowing in (fully aware that it’ll probably slow it all down) - that’s how I know I’m getting all kinds of other MIDI message types too.
I am setting up my MIDI handler like so:
MidiUartHandler::Config midiConfig;
midi.Init(midiConfig);
midi.StartReceive();
And in my main while(true) loop:
midi.Listen();
while(midi.HasEvents()) {
MidiEvent m = midi.PopEvent();
if (m.type == SystemRealTime) {
HandleSystemRealtime(m.srt_type);
}
}
And finally the handler:
void HandleSystemRealtime(SystemRealTimeType srt_type)
{
switch(srt_type) {
case Start: {
hw.PrintLine("MIDI Start");
}
break;
case Stop: {
hw.PrintLine("MIDI Stop");
}
break;
case TimingClock: {
tick_count++;
if (tick_count == 23) {
led_state = !led_state;
hw.SetLed(led_state);
tick_count = 0;
}
}
break;
default: {
}
break;
}
}
Hoping I’ve just done something dumb like forgotten a pull-up resistor. Thanks!