Relation between BAUD_RATE and crystal frequency

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

I want to know the relationship between the baud rate and crystal frequency. There are certain documents stating that if you are using a 16MHz crystal your Baud rate must be 115200 and if frequency is 8MHz then baud rate can be 9600. It also states that the AVR Studio AVRISP accepts only 115200 baud. Is this right ? If true, can I burn the boot loader in arduino IDE at a buad rate of 9600 ?

Thanks,

Srinivasa Varadhan

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

Its all in the datasheet! You want to achieve less than 3% baud rate error using an integer divisor. With Some baudrates with some crystals, this can't be achieved. The datasheet has a table of common crystal freq vs baudrate and the error. It also gives the formula for determining the divisor.

 

edit typo

Last Edited: Mon. Feb 15, 2016 - 07:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Kartman..

 

srinivardhan wrote:
the AVR Studio AVRISP accepts only 115200 baud. Is this right ?

Any solution on this question ?

Thanks,

Srinivasa Varadhan

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

The AVRISP MkII uses usb. No serial involved. So exactly what device are you referring to?

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

Kartman wrote:
Its all in the datasheet!
+1

 

Every AVr datasheet has a section at the end of the UART chapter called "Examples of baud rate setting". This shows tables for common crystal frequencies and for each it lists all the common baud rates from 300 up to 115,200 (and beyond in fact). It shows you the UBRR value you would need to use to get that baud rate using that crystal frequency and very importantly there is a column for "Error %". The baud rate/frequncy combination will be usable if the number in the error column is between -2.0 and +2.0. If it is smaller or larger then it is unlikely to work. For example you will see that for a crystal of 1.0MHz and a baud rate of 9600 the Error% is -7.0%. That means that combination is not usable. You should pick a different baud rate or a different crystal frequency to find some other combination with a better Error%.

 

Sometimes there is a value that is too big in Error% but in the "U2X" column alongside it is in the -2.0%..+2.0% range. In that case it is telling you that you can do it but you need to enable U2X mode (which is slightly more error prone than normal mode as it only over-samples by 8 times rather than the usual 16 times).

 

If you use a frequency that is not a "common" crystal frequency you won't find an entry in the table. In this case you need to use the formulae given in the datasheet to calculate it yourself.

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

Thank you Kartman and clawson,

 

I referred to the data sheet in the segment you cited. I understood the reason.

Kartman wrote:
So exactly what device are you referring to?

Yes I am referring to USB only.

Thanks,

Srinivasa Varadhan

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

So what does the uart baud rate got to do with USB? SPI is used to communicate with the AVR and no boot loader is used. So the baud rate of 115200 is irrelevant.