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

calculation of the baud rate

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



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

calculation of the baud rate
PostPosted: Sat Oct 06, 2012 8:37 pm     Reply with quote

During the use of the uart communication (rs232) how to calculate the necessary baud rate??
Ttelmah



Joined: 11 Mar 2010
Posts: 19515

View user's profile Send private message

PostPosted: Sun Oct 07, 2012 2:26 am     Reply with quote

Normally depends on what the other end wants....

However 'calculation', well there are a lot of things that affect the rates you _can_ use. No calculation as such, except in balancing the factors.

First, cable length. The longer the length you require, the lower the rate you are allowed to use. This is in the RS232 specifications.
Second how much data you want to transfer. Basically 9600bps, gives almost 1000 characters per second. If your application needs more, then you have to go faster.
Then reliability. The noise margins etc., go down with increasing frequency. Generally data error rates rise as you push the rates up.
Fourth hardware limitations. The transceivers used for the bus will have limits, and the faster data is arriving, the quicker your code will have to be.
Then the only PIC hardware limitation. Depending on your clock frequency used by the PIC, there will be a percentage error in the baud rate actually generated. Generally this rises the faster you try to work. So (for instance), working with a 20MHz crystal, and a PIC16, at 19200bps, there is 1.72% error, but at 57600bps, there is 8.51% error. The maximum total error on the bus (both ends) should be kept below about 4% for any hope of reliability, so with this chip/clock, 57600 is unuseable.....). Now this can be avoided by choosing a master oscillator that is a multiple of the standard UART frequencies. So (for instance) using a master clock at 18.432MHz, though slower, gives a 'perfect' baud rate at 57600 (and at most other rates).

Basically data sheets.
Start with the PIC data sheet which shows how baud rate division is done, and usually lists some examples with their rates.
Then an RS232 specification sheet (National Semi do the best).
Then the data sheet for the driver you want to use, and for the wire.

However the 'other end' is the biggest starting point. For instance if you are talking to a GPS, the original standard for their communications is 2400bps, with later moves to 9600bps. Most common instrument protocols use 9600bps, or 19200bps (this is the fastest rate supported at the maximum original specified cable length for RS232 - hence it's popularity).

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