4 x Serial I\O
Thomas Brandon email (remove spam text)
I am looking at a project involving 4 MIDI interfaces (both in & out). MIDI
is a 31250bps NRZ comms scheme. As well as the I\O there are quite a few
other things going on such as routing of the messages, ADCing of knobs and a
possible USB interface down the track. I can't foresee any problems with 4
outputs, you could simply have them synchronised. You'd need a couple of
extra instructions to get the 4 bits as a nibble, but if you had one nibble
of a port as in and the other as out you could simply write to the whole
port without effecting input. I can't foresee any problems with this. In the
case that other port pins were used as ouputs you would need to read, AND,
OR and write, still not too bad. 31250bps = 32us\bit, on a 20MHz (5MIPS) pic
that's 160 instructions\bit. Unlesss the reciever latched the data on the
rising edge of the clock, I can't see any problems, I should really be able
to be as much as 20 instructions late in writing the data with no problems,
as long as I don't lose time.
The main problem is 4 channels of MIDI in. In theory I think it should just
about be possible. The main problem is keeping the timing.
I could either poll the 4 inputs or have interrupt on falling edges (Stop
bit -> start bit).
Interrupts are a bit slow and nondeterministic, at least with 4 external
interrupts (incoming start bit) and 4 internal interrupts (4 outbound
channels). By synching the outputs and having only 1 internal interrupt it
gets better. But I still don't have a lot of leniency in the external
interrupt response. I would have to have a very efficent method of quickly
noting the timing of that channel for subsequent polling. The other problem
with external interrupts is I have to keep disabling them for the data bits
or else I will get extra interrupts due to falling edges in the data.
However straight polling implies a fair bit of logic to determine if the
values changed and if it has changed what that means (start, data, stop,
The other options are of course external UARTs or a Scenix. I have
investigated external UARTs but have yet to find a suitable one I can
actually get here in Australia. The MAX3100 is pretty good, nice and small,
the only problem is sourcing them here. I have yet to find an Australian
supplier stocking them and Digikey doesn't have them in their catalogue. I
can get them through the Maxim small orders but the price is pretty poor
(they're charging more than digikey for 1-25) and I'm up for US$50 shipping.
Apart from that the only UARTs I've seen are the National 1655x series. I
can get the 16550 from Dick Smith but at AU$20ea, I can get 4 16F84's for
less and have 'intelligent' UARTs (or DUARTs). I am yet to find an
australian stockist of the 16552 DUART, and it's PLCC only which I'd rather
avoid. And, even the MAX3100 is pretty innefficient in many ways. I don't
need flow control or anything just RX and TX. Yet I have to pay for, and use
board space for these features.
In terms of Scenix's, they are in many ways an attractive alternative. My
main problem with them is lack of experience and their sensitivity. I'm not
exactly a pic expert (and there pretty similar) so the sensitivity is more
of an issue (particularly in relation to my poor electronics knowledge).
Has anyone implemented multiple UARTs in a single pic? Anyone think it'd be
possible? Anyone suggest an alternative external UART?
seeking: microchip devices pic
See also: www.piclist.com/techref/io/serials.htm?key=serial
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the