PIC16F88 MIDI filter using interrupt Rx function..

Thread Starter


Joined Mar 18, 2014
I'm using a PIC16F88 as a MIDI command filter.
It runs @ 8mhz (internal clock).
Every bytes received on the MIDI input at 31250bauds
must be looped back to a MIDI output but the MIDI command '0xFE'
which is the 'Active Sensing' sent any 0.5 sec. or so..
This byte must be intercepted.
I want to use an RX interrupt function in the process.
So I want to let pass all the received bytes but the '0xFE'.
My question is:
Can I fill the PIC Tx register with any acceptable received bytes
-->inside the Rx interrupt routine<---
and not in a polling loop inside the main() program ?
Will-it be any possible loss of byte(s) because
of the waiting of 'Tx ready' flag to do so ?


Joined Feb 24, 2006
That would not be my first choice. It would be far better to buffer the RX byte and enable the transmit interrupt. Let the transmit interrupt sequence the bytes from the trnasmitter. Ask yourself what the Rx interrupt should do if the transmitter is busy. Wait for the transmitter to be free, and risk having the next receive byte overrun the current one? Rx and Tx interrupts are separate for a reason.

Just to be clear the processing of the Rx byte and the echo to the transmitter should not happen in the Rx interrupt routine. The only thing that should happen there is unloading the RxData register and getting setup to receive the next byte. Similarly the only thing the transmit interrupt routine should do is pick up a byte from memory and write it to the hardware.