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 support@ccsinfo.com

#USE RS232 Errors explain...

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



Joined: 07 Sep 2003
Posts: 19
Location: South Africa

View user's profile Send private message

#USE RS232 Errors explain...
PostPosted: Sun Mar 21, 2004 2:35 am     Reply with quote

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: 1913
Location: Norman, OK

View user's profile Send private message

ERRORS handling
PostPosted: Sun Mar 21, 2004 9:54 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 12:41 am     Reply with quote

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

View user's profile Send private message

PostPosted: Tue Mar 23, 2004 8:27 am     Reply with quote

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
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