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

Auto-adjustable baud rate for RS232

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



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

Auto-adjustable baud rate for RS232
PostPosted: Mon Dec 02, 2013 3:46 am     Reply with quote

Greetings! How can I make my UART interface to choose his baud rate himself according to the baud rate of the income data?
Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19540

View user's profile Send private message

PostPosted: Mon Dec 02, 2013 4:56 am     Reply with quote

Depends on the chip.

Number of approaches:
1) Choose a chip with auto baud abilities, and look at the Microchip application notes about this.
2) Simply ensure the transmission code generates a sequence of 'known' characters for a moment at startup. STX is a common choice. Have the chip _not_ enable it's UART, and monitor the serial line. Time the pulses, and shortest one gives the bit time. Enable the UART, and set it's baud rate based on this. You can either time using a simple counter, or (more accurate), use a CCP. STX is 'nice', since it has a single 'high' bit, which is relatively easy to identify.
3) Do a 'tune' algorithm based upon detecting framing and data errors, and search for the best rate.

For '1', beware that quite a few of the more basic chips (16F688 for example), have large errata about this....
AN962, describes approach '2' for the '30' DSPIC's, where the input can be routed internally to a CCP.
'3' can give problems when the rates are even multiples of one another, with no errors being detected.

Best Wishes
stoyanoff



Joined: 20 Jul 2011
Posts: 375

View user's profile Send private message

PostPosted: Mon Dec 02, 2013 5:30 am     Reply with quote

OK! One more thing! I took a look at dsPIC30 series and the datasheets say their operational voltage is 2.5-5.5V. Does it mean they can work on 3.3V?
temtronic



Joined: 01 Jul 2010
Posts: 9243
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Mon Dec 02, 2013 6:21 am     Reply with quote

yes...
simple datasheet101
BUT
be sure to look at what SPEED it can run at that voltage !
There are charts and figures that graphically show what is allowable.
Be sure to read and reread that section !
AND
check to see what 'clock' can run at that voltage as some combinations probably are not allowed.
key point is to read the datasheet several times to understand what's OK.

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