> Interesting. I was having a discussion with one of my Master's students > yesterday on a very simular project: RS-232@38400 BPS to MIDI@31250 BPS. > During the discussion we were considering attaching 2 UARTS controlled by > a PIC, but a bit later on it occured to me that maybe this project can be > done using 2 16C84's each managing one part of the serial link (one way for > now) and using a parallel bus to transmit info from one to the other. I'll > of course discuss it with him the next time I see him. The best approach for a MIDI <--> 38400,m,8,2 converter would be to have one 16C84 convert from 31.25Kbps to 38.4Kbps, and have the other convert from 38.4Kbps to 31.25Kbps; there would not need to be any communication between the two PICs then. Although in the general case sending and receiving at different baud rates is hard, in this application you would have the advantage that sending and receiving count be synchronized. For example, at 38.4K, one bit is 26us; at 31.25K, it's 32us. Then to convert from 38.4K to 31.25K, run the follow- ing: Loop: If input is high, loop Set time zero. At time 13, if input is high, loop. At time 16, set output low. At time 39, read input into ibit0. At time 48, set output to ibit0. At time 65, read input into ibit1. At time 80, set output to ibit1. At time 91, read input into ibit2. At time 112, set output to ibit2. At time 117, read input into ibit3. At time 143, read input into ibit4. At time 144, set output to ibit3. At time 169, read input into ibit5. At time 176, set output to ibit4. At time 195, read input into ibit6. At time 208, set output to ibit5. At time 221, read input into ibit7. At time 240, set output to ibit6. At time 272, set output to ibit7. At time 304, set output high. The above can, of course, be implemented fairly easily using PIC code and will have lower propagation delay than receiving and transmitting a while UART byte. Going the other direction (31250,n,8,1)->(38400,m,8,2) is a little trickier, but not hard if you wait a few bit times before starting the reverse transmission: Loop: If input is high, loop Set time zero At time 16, if input is high, loop At time 48, read input into ibit0 At time 55, set output low At time 80, read input into ibit1 At time 91, set output to ibit0 At time 112, read input into ibit2 At time 117, set output to ibit1 At time 143, set output to ibit2 At time 144, read input into ibit3 At time 169, set output to ibit3 At time 176, read input into ibit4 At time 195, set output to ibit4 At time 208, read input into ibit5 At time 221, set output to ibit5 At time 240, read input into ibit6 At time 247, set output to ibit6 At time 272, read input into ibit7 At time 273, set output to ibit7 At time 299, set output high Note that both of these conversion algorithms could easily fit within one PIC device and an external switch could be used to select between them. Alternatively, if the times above were rounded off 'slightly', it would be possible to use a simple 'multi-tasking executive' to run both simultaneous- ly.