is a UART required for sending MIDI messages with a PIC?

Started by tempus, September 15, 2011, 06:02:22 PM

Previous topic - Next topic

tempus

Hey all;

I'm trying to design a MIDI program change pedal around a PIC uProcessor. I've got everything all worked out I think, but I was wondering about which PIC to use. If all I'm doing is sending MIDI messages, do I need a UART, or can I get away without one? I really only need 2 pins from the PIC itself (one for a switch input and one to send out the MIDI message) so I could use a much smaller device if I don't need the UART.

Thanks


Gurner

Assuming this isn't for a production run (where saving cost is a major driver) the whole thing about spec'ing a pic is to ensure it has the features/peripherals you intend using...since midi uses serial, better to go with a PIC with uart. Something like an 8 pin 12f1822 is cheaps as chips and probably just 50c more than a uart-less PIC  (in answer to your question, no you don't *need* a uart...but why avoid one?)

PRR

You just need to blink an LED.

But relatively slowly compared to CPU speed. (Fast compared to finger-speed.)

If your CPU/PIC has nothing else to do during this time, sure, use counter delays to blink the LED at a rate that MIDI systems will understand.

If the CPU has better stuff to do, off-load the MIDI byte to a UART (maybe on-board; or another PIC) so it can get back to heavy thinking while the dumb chip does the tedious blinks.
  • SUPPORTER

R.G.

You have two choices: get a PIC with an internal UART, or use programmed bit handling and timing (in the parlance of PICs, "bit banging") to simulate a UART in the program. You simply must produce output bits that conform to the timing and bit-structure of MIDI, which is current-loop RS232 done with a non-standard timing.

My experience has been that bit banging is more trouble than it's worth unless you are driven to it by some other and more important constraint than an additional US$0.50 per processor. The complexity of the program to meet real time constraints gets out of hand if you can simply get a bigger processor and avoid it.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Gurner

Also, if you intend using interrupts in your main code, then implementing a pseuo uart (by way of bit banging) will inevitably end up as a corrupted midi datastream ....like I say, just splash out the extra 50c and get a PIC with a uart!

tempus

OK thanks for the info. I had no intention of trying to write code to simulate the UART, I thought that maybe the UART was needed for MIDI send and receive. Since I was only sending I wasn't sure that I'd need it. Also, I didn't realize that there was an 8 pin DIP with a UART, so I'll look into that (the issue was more the size of the IC/unused pins than the cost).

Thanks again everyone.