CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

PIC to PIC interfacing by RS485

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
fuzzy



Joined: 26 Feb 2005
Posts: 64

View user's profile Send private message

PIC to PIC interfacing by RS485
PostPosted: Sat Feb 26, 2005 12:28 pm     Reply with quote

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

View user's profile Send private message Send e-mail

PostPosted: Sat Feb 26, 2005 6:00 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Sun Feb 27, 2005 7:24 am     Reply with quote

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







PostPosted: Sun Feb 27, 2005 7:38 am     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Mar 03, 2005 3:33 pm     Reply with quote

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!!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group