View previous topic :: View next topic |
Author |
Message |
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
PIC to PIC interfacing by RS485 |
Posted: Sat Feb 26, 2005 12:28 pm |
|
|
Hi,
I'm trying to connect 2 PIC16f876 by rs485 using SN75176 transceiver. I'd like to use half duplex configuration, so i control RE and DE pins togheter by Port C5 that is always 0(receiving). It will be set 1 before transimitting and then it returns to 0.
I use pins C6 and C7 to receive and transmit data.
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,enable=PIN_C5,parity=n)
I've some problems in comunication.After a lot of attempt i realized that When one PIC transimts data it seems as it receives what it has transmitted and this will fill in receiving buffer. so the transimitting pic receives the same data it sends. and when the other pic tryes to send data the first pic can't decode data.
I tried all configuration suggested in datasheet to remove bias, with 120 ohm resistors and so on but it's the same. so i should exclude problems on the line.
What will you suggest to try? how can i solve this problem?
thanks! |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Feb 26, 2005 6:00 pm |
|
|
It is because the receive and transmit are on at the same time. Are you sure that you connected them together and there are no shorts. |
|
|
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Sun Feb 27, 2005 7:24 am |
|
|
RE and DE pins are together and they goes high only when PIC transimts.
i'm afraid the pin C5 controlled by software of rs232 goes down before PIC stops transmitting. Is it possible? but I also tryed to force high this pin for a long period during transmission but the problem was the same.
thanks |
|
|
Ttelmah Guest
|
|
Posted: Sun Feb 27, 2005 7:38 am |
|
|
fuzzy wrote: | RE and DE pins are together and they goes high only when PIC transimts.
i'm afraid the pin C5 controlled by software of rs232 goes down before PIC stops transmitting. Is it possible? but I also tryed to force high this pin for a long period during transmission but the problem was the same.
thanks |
The key here is to remember that transmission only stops, when you have sent all the characters, and then the TRMT bit goes high. After sending the last byte, wait for this to rise before changing the buffer to receive. Beware also, that when you disable the receive buffer (by pulling RE high), 'RO', goes to a 'float' state, which may result in the receive pin on the PIC detecting garbage. Add a high value 'pullup' resistor on the line from the RO pin to the receive data input of the PIC (100K), to prevent this happening.
Best Wishes |
|
|
fuzzy
Joined: 26 Feb 2005 Posts: 64
|
|
Posted: Thu Mar 03, 2005 3:33 pm |
|
|
i finally managed it! now my two pic communicate correctly without any fault. i didn't set correctly TRISC. as I set TRISC.7=1 the system began to work!! |
|
|
|