Well, It’s great to have something work. I finally got it to send out MIDI clock messages and my sequencer accepted them. Yay!
One thing I had a lot of trouble with was understanding the MIDI signals. I couldn’t seem to find much documentation on them. I had to do a lot of trial-and-error and also use my CRO to analyse the signals coming out of some MIDI equipment. Here’s what I found:
MIDI works by current, not voltage. The receiving end has a 1k input impedance and the sender is expected to put a 5V voltage differential across this which produces a current of 5mA. Current flow is indicative of a logic 0. No current flow is a logic 1. There is no current flow when the line is idle.
A fairly standard way to implement a MIDI output is to tie pin 4 of the DIN plug to 5V and pin 5 to your digital output. This forms a hardware inverter so you can use normal logic levels in your circuit.
The data rate is 31250 bps +/- 1%
Another confusing thing is that nowhere is it described how the serial data is sent. The literature will tell you that there is 1 start bit, 8 data bits and one stop bit. Great, just like RS-232 I thought. Well no, it’s not anything like RS-232. The start bit in MIDI is a 0, the stop bit is a 1 and the data bits are sent in reverse order. All perfectly fine but I had to discover this myself.
The firmware is now over 1000 lines and is almost finished. I’ve just got to figure out how to store the BPM setting in the internal EEPROM and it’s done.