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

How to check that rs232 communication was established ?

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



Joined: 17 Sep 2005
Posts: 6

View user's profile Send private message

How to check that rs232 communication was established ?
PostPosted: Sat Sep 17, 2005 3:48 pm     Reply with quote

Hi
I am using rs232 to communicate between a pc and a pic (16F877) . My question is how do I check that the computer is connected to the pic (from the pic "point of view") ?
I would like to flash a LED if the communication is lost.

Thanks Amnon Shocked
Ttelmah
Guest







PostPosted: Sun Sep 18, 2005 2:53 am     Reply with quote

The RS232 line at the pic, idles 'high'. If the link is broken, it'll go low (assuming you are using a normal RS232 transceiver), and you will receive continuous '0' bytes, with the 'framing error' status bit set (I am assuming you are using the hardware UART). This is the 'break' condition (this is why it has this name).
I suggest that in your UART code, you check FERR bit, and if it is set, read the byte. If this is 0, you can flag the link as broken.

Best Wishes
Amnon



Joined: 17 Sep 2005
Posts: 6

View user's profile Send private message

PostPosted: Sun Sep 18, 2005 4:44 pm     Reply with quote

Ttelmah hi.
Thanks for your answer.
I must say that I am really a novice in the pic and the CCS filed' that is way I got some more questions (and they may be stupid questions) :

1. My I check the TX and RX pin status with simple input command?
2. How do I check the FERR bit from CCS?
3. can you , or any one give me a code as a reference ? I am not sure I understood Ttelmah explanation thoroughly , So I will write it in my own words:

Check the RX and TX pin ,
If high -> connection is ok.
If low , check FERR
If high -> No connection.
If low -> connection is ok.

Did I understand the explanation ?


Thanks Again Amnon Shocked
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Sep 18, 2005 4:58 pm     Reply with quote

Quote:
The RS232 line at the pic, idles 'high'. If the link is broken, it'll go low (assuming you are using a normal RS232 transceiver), and you will receive continuous '0' bytes

I don't think this will happen, because if you have a MAX232-type chip
on the PIC board, the receivers inside that chip have pull-down resistors
on their input pins.

Look on page 17 of the data sheet. On the right-hand side, it shows the
5K resistors which pull down to ground. (on pins 13 and 8).
http://pdfserv.maxim-ic.com/en/ds/MAX220-MAX249.pdf
On page 2 of the data sheet, it shows the "RS-232 Input Threshold Low"
is 0.8v minimum. So a pull-down to ground will put a Logic 0 into the
inverter. It will be inverted to a Logic High, and sent to the Rx pin
on the PIC. This is an idle state. So the PIC won't notice that the
connection has been broken.
Humberto



Joined: 08 Sep 2003
Posts: 1215
Location: Buenos Aires, La Reina del Plata

View user's profile Send private message

PostPosted: Sun Sep 18, 2005 6:22 pm     Reply with quote

Amnon wrote:
Quote:

My question is how do I check that the computer is connected to the pic (from the pic "point of view") ?


The way of doing this in RS232 is using handshakes.

It can be achieved by:
1) hardware using the de facto Control lines established by the standard.
DSR Data Set Ready [DCE --> DTE]
DTR Data Terminal Ready [DTE --> DCE]

2) software sending a recognizable character at regular intervals and waiting
the answerback of the remote connected device.


Humberto
Amnon



Joined: 17 Sep 2005
Posts: 6

View user's profile Send private message

PostPosted: Sat Sep 24, 2005 7:20 am     Reply with quote

Humberto
Thanks for your answer , and sorry it took me so long to get back to you.

Quote:

1) hardware using the de facto Control lines established by the standard.
DSR Data Set Ready [DCE --> DTE]
DTR Data Terminal Ready [DTE --> DCE]


So as I understand from your answer , I should check the DSR DTR.
But I'm using just the RXD and TXD pins.

I am using the hardware UART of the 16F877 .
And I would like the read other suggestions , especially with out writing to the PC and waiting for ECHO.

Thanks again Shocked
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