??? 07/14/04 19:02 Read: times |
#74255 - RE: serial buffer and MIDI message handling Responding to: ???'s previous message |
John,
I've written quite a few MIDI interfaces using '51 processors. A 89C2051 executing at 12Mhz is more than fast enough to handle a single incoming MIDI input (with enough freeboard to generate LFO and Noise modulation). If you need to handle two inputs you may be using a two UART variant which probably allows faster execution rate and may even implement fewer clocks per machine cycle (i.e. Dallas '320/420, etc) which eases MIDI implementation. Two implementation approaches are common in handling MIDI; an "on the fly approach" (where you frame messages as you recieve individual bytes based upon the state of the MSB to synchronize against Status Bytes) and alternatively, using a circular buffer where input occurs due to the recieve interrupt service routine and message framing occurs occurs in the foreground. My preference is the buffer based approach as the interrupt routine retains a small footprint and execution time while also avoiding buffer conflict that can occur with the on the fly approach. The typical short falls of MIDI interface code is mis-handling of REAL TIME and RUNNING STATUS messages types. Real Time messages being single bytes are allowed to occur anyplace and often occur withing the body of another type of MIDI message. This not only means that you must protect your message framing from these "errant" Status Bytes but you must also not let them "change" your Running Status. Common problematic Real Time messages which are the MIDI Clock and Active Sense messages. Many MIDI interfaces to just "drop these on the floor" (unless they are being used). If you are interested in some MIDI handling code pls. let me know. regards, p |