View previous topic :: View next topic |
Author |
Message |
Amnon
Joined: 17 Sep 2005 Posts: 6
|
How to check that rs232 communication was established ? |
Posted: Sat Sep 17, 2005 3:48 pm |
|
|
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](images/smiles/icon_eek.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Sun Sep 18, 2005 2:53 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Amnon
Joined: 17 Sep 2005 Posts: 6
|
|
Posted: Sun Sep 18, 2005 4:44 pm |
|
|
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](images/smiles/icon_eek.gif) |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 18, 2005 4:58 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
Humberto
Joined: 08 Sep 2003 Posts: 1215 Location: Buenos Aires, La Reina del Plata
|
|
Posted: Sun Sep 18, 2005 6:22 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
Amnon
Joined: 17 Sep 2005 Posts: 6
|
|
Posted: Sat Sep 24, 2005 7:20 am |
|
|
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](images/smiles/icon_eek.gif) |
|
![](templates/subSilver/images/spacer.gif) |
|