One difference with RS485 in 2 wire mode (half duplex) compared to RS232 is that the transmitter has to be enabled during transmitting (obviously!) only. With RS232 communication on a PC you only have to bother with 'Transmitter Holding Register Empty' (THRE) interrupt when transmitting, to know when you can put the next character in the transmitt holding register. With RS485 you also have to check 'Tx Shift Register Empty'(TSRE) for the last character so you know when to turn off the transmitter. The THRE interrupt tells you when you can put a new character in the THR register but that doesn't mean that the previous character is sent, only that it is transfered to the shift register. The TSRE interrupt, however tells you that there is no more characters in the THR register and that the TSR register is empry, that is, the last bit of the last character is sent. Sometimes it is also necessary to have a little delay between the transmitting and the turning off of the transmitter. One way to come around this on the PC (the master) is to have 4 wire comunication (full duplex). Here the master is the only transmitter on 2 of the wires connected to all the slave recievers and all the slave transmitters are connected on the other 2 wires to the master receiver. This way the master can have it's transmitter enabled all the time and the software can work as a standard 3 wire RS232 aplication. (From the transmitting side on the PC it looks lika RS422 communication.) >From: Tom Mariner >Subject: Re: 2 Pics on one crystal (Part 2) To: > > (2) Somebody on the list recently indicated that it was easy to convert > > from RS232 to RS485, I have no problem at the PIC level but without > > purchasing an expensive RS485 Card for my PC which is intended to be the > > master controller in a multi-drop system I am having difficulty in enabling > > the RS485 driver from a standard PC RS232 port while transmitting and then > > disabling the driver and still be able to listen for a reply on the PC > port. > > Not easy to go from RS-232 to RS-485, since one is going from point to point > to a multidrop environment. We did it on a 16C57 with an interesting amount of > circular buffers, multitasking and network processing. (One has to treat the > 485 connection as a network with some sort of protocol to keep terminals from > killing each other's messages. I like CSMA/CD, but there are other token > passing, etc. schemes that also work.) > > The RS-232 connection into the PIC becomes just a drop on the net with an > address so it can read / write to / from any other point. Obviously speed > matching becomes a real problem unless the same speed and / or tiny packets > are used. > > Tom > ------------------------------------ Ruben Jonsson AB Liros Elektronik Box 9124 200 39 Malmo Sweden Tel +46 40 14 20 80 Mail: ruben@sbbs.se ------------------------------------