View previous topic :: View next topic |
Author |
Message |
stoyanoff
Joined: 20 Jul 2011 Posts: 375
|
Auto-adjustable baud rate for RS232 |
Posted: Mon Dec 02, 2013 3:46 am |
|
|
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
|
|
Posted: Mon Dec 02, 2013 4:56 am |
|
|
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
|
|
Posted: Mon Dec 02, 2013 5:30 am |
|
|
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
|
|
Posted: Mon Dec 02, 2013 6:21 am |
|
|
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 |
|
|
|