PIC chips and midi stuff

Fraser, Colin J Colin.Fraser at scottishpower.plc.uk
Fri Mar 3 10:54:50 CET 2000

> -----Original Message-----
> From: Rob [mailto:cyborg_0 at iquest.net]
> Sent: 03 March 2000 03:58
> To: synth-diy at mailhost.bpa.nl
> Subject: PIC chips and midi stuff
> I just started a program that
> will take midi beat clocks and divide it in various ways and 
> spit it out a
> couple of midi ports at the same time changing midi beat 
> clocks to triggers
> and sending it out. I know this one will be a timing 
> nightmare but Im going
> to try it nonetheless. At an internal clock of about 2.5mhz 
> it should work
> without too much prob. Ive already got the basic version of 
> it working and
> it sims out perfectly.
> BTW, once I get the code going, I will post it to my page 
> with a little
> tutorial of what I did so you can manipulate it or add to it, or just
> program and build it yourself. 

If you're using a PIC that doesn't have an in-built UART, you want to use a
higher clock speed than 2.5 Mhz.
The code for my midi to sync convertor is on my web site, and includes soft
midi reception.
This depends on using loops to time the incoming bits, and even at 4 MHz on
12c508, the timing is quite tight.

> Im a little worried about my algo for my midi reception. 
> Someone told me the
> start bit comes AFTER the status message? This isnt right is it?

The output of the opto-isolator will normally be high - logic 1.
The start bit arrives first, and is 0.
Then the 8 bits of the byte arrive, lowest bit first, then the stop bit is a
After the stop bit, if there are no further messages, the line sits at 1.

Remember that if you don't want to miss any following messages, you need to
be very quick after receiving the stop bit in doing whatever it is you want
to do with the byte you just received.
If you're using midi start and stop messages to reset counters etc, and a
stop message comes immediately after a clock message, you might miss it.

Unless I was going for absolute cheapness, as I was with the sync convertor,
I would always prefer to use a hardware UART for midi reception.
These are much more reliable than the software method, as they sample the
incoming data at a much higher rate than the actual baud rate, and thereby
include some noise rejection. 
They also don't tie up your processor while they receive another byte.

Colin f

More information about the Synth-diy mailing list