View previous topic :: View next topic |
Author |
Message |
Guest
|
De-energized UART issue |
Posted: Tue Aug 23, 2005 3:34 pm |
|
|
I am using a PIC 16F88 for UART-to-UART serial communications. The external UART will be powered up and down while the PIC stays powered up. When the external UART is powered down, the PIC will see a clear signal level (0 volts) on its RX line. The PIC will see this as a start bit and then read 8 bits worth of zeros into the RSR. I am concerned that this condition will cause the PIC to read a lot of spurious data.
The only brake on this seems to be the stop bit (set signal level or high voltage), but the manual isn't clear. The manual mentions the PIC transfers data to the RCREG "after sampling the stop bit". Then it mentions the framing error flag, "FERR is set if a STOP bit is detected as clear".
Anyone know if a clear stop bit will inhibit loading the RSR into the RCREG? Is there some hardware trick like using a large value resistor to pull the RX line high to keep the PIC from seeing the low voltage condition caused by the de-energized external UART? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 23, 2005 3:46 pm |
|
|
Are you using a MAX232-type chip ? They have pull-down resistors
on their RS-232 input pins. If there's no signal driving the input
pin, it will be held at zero volts. After the inversion inside the MAX232,
the PIC will see a high level, which is a stop bit. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1636 Location: Perth, Australia
|
|
Posted: Tue Aug 23, 2005 5:52 pm |
|
|
Don't forget to ensure that the PIC does not drive any lines high to the powered down uart as this could a) destroy the UART or b) keep the UART powered up via the input protection diodes. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
Guest
|
|
Posted: Wed Aug 24, 2005 4:04 pm |
|
|
No MAX232. This is a direct hardwire from the UART output to the PIC. I am using only the TX from the UART into the RX of the PIC. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Aug 24, 2005 4:10 pm |
|
|
Are you using the hardware UART in the PIC ?
If so, add a 10K pullup to the Rx input on the PIC.
(The pullup is to the same Vdd that runs the PIC).
Are you using a software UART with the INVERT option in the PIC ?
If so, then add a 10K pull-down to the Rx input on the PIC.
(The pull-down is to Ground). |
|
|
Guest
|
|
Posted: Thu Aug 25, 2005 10:20 am |
|
|
Yes, I am using the PIC hardware UART. The pull up resistor sounds like a good idea. I am also interested in a technical discussion of how the PIC UART works. For example if the stop bit is low, will it still load the data into the RCREG? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Aug 25, 2005 11:13 am |
|
|
Quote: | Yes, but you will get a Framing Error from the USART. This won't lock up the USART. |
Unless you don't read the value in which case you will eventually get the buffer overflow which as PCM pointed out will lock up unless you handle the error. |
|
|
Guest
|
|
Posted: Thu Aug 25, 2005 1:00 pm |
|
|
I modified my code to run an experiement to determine if the UART would transfer data from the RSR to the RCREG if the stop bit was low. The results indicate it does not.
The TX output of the external UART is low when the UART is deentergized. It goes high when energized. A second or so after power up the external UART starts transmitting a fixed data stream.
I am using the PIC hardware UART with the ERRORS parameter and a INT_RDA handler. Since I am interrupt driven on RDA, I presume I am clearing out the FIFO.
In the experiment I release the PIC and several seconds later energize the external UART. This give the PIC plenty of time to sample the low signal from the external UART TX. I capture the first 64 bytes in a RAM buffer then transfer to EEPROM so I can see exactly what the PIC saw. The data shows a single <NULL> character followed by the expected fixed data stream. Based on this I surmise that the single positive transistion caused by power up is read as a high stop bit. The data prior all had low stop bits and presumably were not validated and therefore not transferred to the RCREG. This is why there is only a single <NULL> instead of a bunch of them. Seem reasonable, or is there another explanation? |
|
|
treitmey
Joined: 23 Jan 2004 Posts: 1094 Location: Appleton,WI USA
|
|
Posted: Fri Aug 26, 2005 7:18 am |
|
|
Don't presume your clearing the fifo/RCREG.
At startup. AND I TAKE THIS FROM THE MANUAL
In PIC18F452 manual page 176 section 16.2.2
step 1..6
setp 7 read rcsta
step 8 read RCREG <--- This clears the fifo
step ...9...
then turn on IRQ.
This ensures you startup clean. |
|
|
bkamen
Joined: 07 Jan 2004 Posts: 1615 Location: Central Illinois, USA
|
Re: De-energized UART issue |
Posted: Fri Aug 26, 2005 8:10 am |
|
|
So wait - you're not using an external RS232 interface level converter at all? Just the 2 PICs of which one powers off? Why not have a "dtr" line?
Then you'd have a means of "handshaking" unless it's too many lines.
If you used a chip like the MAX221 which has an ~INVALID output and features like auto-shutdown, then you can hook the ~INVALID to something like RC5 (typical in some of my application) and use is as a DTR line as when the receive signal to the MAX221 is non-existant, ~INVALID goes active and you know the other end is either missing or asleep.
Just a thought...
-Ben |
|
|
|