Auto Baud Calibration

Go To Last Post
13 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello,

I want to know about auto baud calibration method. I searched in net but i couldnt get a good tutorial. Can anyone share any links or knowledge about it.

Thanks in advance

-Krishna Balan S

-------------------------------------------------------------------------

"Heroes are ordinary people with extraordinary commitment"

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Using Search on this forum: https://www.avrfreaks.net/index.p...

< typo corrected >

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

Last Edited: Thu. Feb 10, 2011 - 03:56 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I did this by simply wiring the RXD line to an INTn pin and then using a timer with the ext-int to measure the width of the start bit (but this required a character to be transmitted in which the top bit of the data byte was a bit transition from the start bit). Given time again I might have wired RXD to an ICP line directly rather than "hacking it" in an ext-int.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
I did this by simply wiring the RXD line to an INTn pin and then using a timer with the ext-int to measure the width of the start bit (but this required a character to be transmitted in which the top bit of the data byte was a bit transition from the start bit). Given time again I might have wired RXD to an ICP line directly rather than "hacking it" in an ext-int.

So you are saying that you just connect the Input Capture Pin to RXD?
And you just send a byte first of which the MSB has to be 1. So this first byte is like a calibration byte?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Correct. I just had the user hit [Enter] in fact. In the good old days modems used the A of "AT".

In fact I did two things as I was doing things "on the cheap". To save the cost of a crystal I used the (inaccurate) internal RC. So I actually used the measured start bit width first to determine which wide ball-park the baud rate was in then having determined this I used it more accurately to program OSCCAL to get the int-RC closer to the desired baud rate.

(with hindsight I'm not sure I'd recommend this and would just put a "magic crystal" into the design but still use the "ball-park" thing to auto-baud)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have to ensure the LSB is a 1 , not the MSB. Data is sent LSB first,folowing the low start bit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You just reminded me that RS232 is "backwards" isn't it? So the reason [Enter] or the A of "AT" work is that they have byte codes 0x0D and 0x65. Both are "odd" character codes so the bottom bit is '1'. Bit 0, not bit 7 follows the start bit.

(it has to be this way round because there may only be 5, 6, 7 or 8 data bits after the start bit).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
RS232 is "backwards"

Surely you mean that the standard asynchronous serial format is "backwards"? RS232 simply defines the signalling levels, as I understood it.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

0x65 is an e, 65 would be A, but like you say it's odd so the required bit is set.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If a crystal is used, and the set of baud rates is known, it should be possible to just count the start bit length in a loop.

I don't know how much overhead it would be in C code, but in assembly instructions, the wait-until-RXD-low loop would have bout three to for cycles, and increase-register-while-RXD-low loop would have about four to five cycles per loop, right?

Other thing is if baud rates are 2x multiples of each other, transmitting few special values out could help determine baud rate. Say one bit, start bit only, at 4800bps, would be 8 bits at 38400, 4 bits at 19200, 2 bits at 9600. Even if baud rate is unknown, long enough low pulses are seen as bytes, so each end could transmit it's baud rate encoded in bursts like morse code - tone frequency does not matter but burst and space lengths encode the used baud rate.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Sorry, my typo A=65=0x41, not 0x65 :oops:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ascii "U" is the most convenient character to do auto-baud with.

A GIF is worth a thousend words   They are called Rosa, Sylvia, Tricia, and Ulyana. You can find them https://www.linuxmint.com/

Dragon broken ? http://aplomb.nl/TechStuff/Dragon/Dragon.html for how-to-fix tips

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Most autobaud trust, that a certain byte was sent.
But if another byte was sent, autobaud detect a wrong baudrate and no further communication was possible.
E.g. the Atmel Flip bootloader do so.
If you type another byte than 'U', the chip was dead forever until the next power cycle.

Thus I use another approach.
I check the duration of two low pulses, if they have the relation 1:4.
This was the case e.g. on the '\r' (0x0D).
Then false bytes are ignored and autobaud was continued until the right byte.

; recognize any byte,
; which contain 1 * bit time low, followed by 4 * bit times low
;                      ____    __    __ __             ____
;e.g. recognize 0x0D:      |__|  |__|  |  |__|__|__|__|
;                          0  1  2  3     5           9
;                                1*T               4*T

Peter