FROM: IL50/GATE/POSTMASTER TO: pic microcontroller discussion DATE: 05-18-98 TIME: 16:05 SUBJECT: Mail failure ------------------------------------------------------------------------------ [021] Message was not delivered due to missing routing file. ------------------------------------------------------------------------------ I have built a 16C73-based MIDI send/receive device with basically the same circuit, using a 6N138. The system ran off a 4 MHz resonator and used polling on the serial port send and receive. Here are several things to look at, given the MIDI interface schematic shown in the GIF file you referenced (see link in quoted original below). 1) The only difference between the 6N138 and 139 is one is optimized for TTL (6N138) and the other for CMOS (6N139). Either should work in this application, and they are pin-compatible. 2) The 6N138/139 (8-pin part) has a different pin-out than the Sharp PC-900 (6-pin part). For the 6N138/139, connect as follows (again referencing the GIF schematic): - MIDI IN Connector pin 4 to 220 ohm resistor - Other side of 220 ohm resistor to cathode of external diode and pin 2 of 6N139 (anode) - MIDI IN connector pin 5 to anode of external diode and pin 3 of 6N139 (cathode) - 6N139 pin 8 to +5V - 6N139 pin 6 (output) to pull-up and PIC input - 6N139 pin 5 to GND - 6N139 pins 1, 4 and 7 are "no connect" 3) Yes, SPBRG=4 should give 31250 baud for 10MHz oscillator IF you set BRGH=0 (and assuming you crystal is really oscillating at 10MHz). 4) You imply that you receive some bytes correctly and some incorrectly. What percentage of bytes do you receive correctly? Are you using interrupts to read the receive register or are you polling? If polling, are you absolutely sure you are polling often enough (with 10MHz osc you should have lots of time between bytes)? Are you checking the overrun (OERR) and framing error (FERR) status bits (and clearing them afterwards)? 5) Are you using a small and known data stream to test the receive, or is it "live" MIDI data. Try using the serial transmit pin (and the rest of the output circuit from the GIF file) to send yourself known data (this will not find baud rate problems, but will trouble-shoot receive hardware and software). I hope this helps. I will try to help if you have more questions. Bob. On Sunday, May 17, 1998 12:19 PM, Catch-It [SMTP:Catch-It@FILETREK.DEMON.CO.UK] wrote: > Hiya, > Can anybody help me? (no smart comments please :-) > > I am trying to get MIDI data into my 16C77. It kind of works, but seems to > get some wrong values through (I have examined the same stream on the PC and > it is being transmitted correctly) > > PIC is running at 10 Mhz (oscillator using 22pf capacitors). SPBRG is set to > 4 (which should give me the 31250 bps right?) > > The circuit I am using for input is basically a standard circuit (see the > input section of http://www.borg.com/~jglatt/tech/midi.gif ), but I am using > a 6N139 opto isolator (because I cannot easily get hold of a 6n138). > > I would imagine that there is a slight difference that I need to get over > but > 1) I have no specs for the 138 to compare with > 2) My analogue electronics is pants > > has anybody got any ideas I could try (like maybe a new hobby :-) > > Regards > Catchy >