MIDI conjunction device

Feb 21, 2006 20 Replies

I don't see a problem implementing this with a single byte delay in interrupt context, just reserve one byte for the input status on each channel and one for the output channel to generate the status on the input and strip redundant status bytes on the output.

The input RxFull interrupt just moves the bytes to input queue (which can hold 0-3 bytes) and when it appears to be overflowing, move a full

3 byte message to the global output queue. If the TxUART is inactive when the first byte arrives at an input channel, that channel can simply enable the OUT UART interrupt and the TxEmpty interrupt will be immediately pending and executed when the Rx interrupt returns. The TxEmpty interrupt selects the next byte to transmit either from the input queue that at that time contains stat (or stat+datA) bytes from the only active channel or from the global OUT queue.

The only nasty thing about using only the TxEmpty interrupts to feed the output UART is the baud rate error problem. If the input baud rate is below nominal and the OUT UART baud rate is above nominal, the TxEmpty interrupt may be executed before the RxFull interrupt for the next byte, in which case the input FIFO is empty and the input channel needs to re-enable the Tx interrupt when the next input byte finally arrives. In this sense, a delay greater than one byte time would make sense.

Paul

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required