View previous topic :: View next topic |
Author |
Message |
picker
Joined: 07 Sep 2003 Posts: 19 Location: South Africa
|
#USE RS232 Errors explain... |
Posted: Sun Mar 21, 2004 2:35 am |
|
|
Can someone please explain why it is necessary to write a handler for the Error directive. I have used the hardware uart for years without even looking at the errors. How do framing and overrun errors occur ? Should I be handling them?
Thanks
Picker |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1933 Location: Norman, OK
|
ERRORS handling |
Posted: Sun Mar 21, 2004 9:54 am |
|
|
I use an exact multiple osc (18.432Mhz) and usually get no errors but you have to plan for every case to allow the system to properly recover if it does.
That is why programs have "bugs" when that very rare case jumps out of the woodwork and you didn't plan for it! |
|
|
Haplo
Joined: 06 Sep 2003 Posts: 659 Location: Sydney, Australia
|
|
Posted: Tue Mar 23, 2004 12:41 am |
|
|
dyeatman is right, plan ahead for all the possible situations!
Overrun occurs when the input buffer is over-written before being read by the program. If the rate of incoming data is faster than the rate of your program reading them, you'll get buffer overrun.
When the receiver has received all of the bits in the data word, it may check for the Parity Bits (both sender and receiver must agree on whether a Parity Bit is to be used), and then the receiver looks for a Stop Bit. If the Stop Bit does not appear when it is supposed to, the UART considers the entire word to be garbled and will report a Framing Error to the host processor when the data word is read. The usual cause of a Framing Error is that the sender and receiver clocks were not running at the same speed, or that the signal was interrupted. (Quoting from http://www.freebsd.org/doc/en_US.ISO8859-1/articles/serial-uart/ ).
A break signal will also result in a framing error. |
|
|
SteveS
Joined: 27 Oct 2003 Posts: 126
|
|
Posted: Tue Mar 23, 2004 8:27 am |
|
|
You can also get errors on start up/wake up. Even if you don't handle the error, be sure to clear the error (which will only be done if you use ERRORS- or do it manually), because an overrun error will stop the receiver from processing incoming data. I found this out the hard way....
- SteveS |
|
|
|