set USART to high baud rate without getting errors

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

Hi,

My system: F_clock 8000000, atmega48

When I run USART on 9600 bps it works ok, with no errors, all characters are received correct on hyper terminal. The same is with 19200 bps. But I need higher speed..
I am working with HT, so when I'm setting to any higher baud rate available in the list, I am getting errors, characters are received not correct.

So, what you could suggest me, to get higher speed?
Use another terminal software? Or maybe there are some settings, that I need to set?

Any help would be appreciated! Thanks!

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

Some higher speeds may require U2X to be used to keep the Error% value below 2% - check the table in the datasheet.

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

thanks!
It works! I can set it to higher speed. But using speeds from the list in HT and with U2X I only can reach 38.4 kbps. But I need some even higher speed. Can I set on HT any manual speed, not from the list? Is there somewhere such an option?

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

What speed do you want? You can do 250K with no error, but most PC UARTs won't do that baudrate. You can do 115K if you use an external crystal that's baudrate friendly. 8mhz is not. As Cliff mentioned, look at the baudrate chart in the datasheet.

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

Look at this (attached below)

It's saying that you can do 2400, 4800, 9600, 14400, 19200, 38400, 250000, 500000 without using U2X.

Then you can do 28800, 57600, 76800 using U2X.

115200 and 230400 are not possible on 8MHz as neither column is < 2%.

If you want to do 115200 then switch to a 7.3728MHz crystal which can do all the baud rates with 0% error (not 250000, 500000 though). It's pretty close to 8Mz so your other processing probably won't notice the difference.

This crystal, like the other "odd numbered" ones (also known as "magic crystals") have a frequency that is a multiple of 300Hz.

Attachment(s): 

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

Quote:

You can do 115K if you use an external crystal that's baudrate friendly. 8mhz is not.

I'm always suspicious when I see "8 MHz". OP, what is the clock source for your AVR?

If the internal oscillator then untuned you are lucky to get as good results as you are seeing.

If a crystal, use a "magic number" such as 7.3728MHz to get good results at the common/"standard" baud rates.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Hy, clock source is 8 MHz external crystal

clawson,

thanks, I have checked that list of baud rates on the data sheet. And as I mentioned on my previous post, I can't get higher than 38.4 k, since double of that (76.8k) is not listed on HT, and other baud rates have to many errors.
I will try with some other terminal software.
Unfortunatly, I don't have 7,3728MHz crystal

Any way, thank you all for info!

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

etminasm wrote:
Hy, clock source is 8 MHz external crystal
I will try with some other terminal software.

That probably won't help. PC's suffer the same problem of having a limited set of baud rates.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

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

Quote:

Unfortunatly, I don't have 7,3728MHz crystal


So, let me get this straight: You have an app where high UART rate is important; you picked a crystal frequency where this is difficult with the common baud rates; you are dismissing e.g. 125bps and 250bps for some reason?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Brian Fairchild wrote:
etminasm wrote:
Hy, clock source is 8 MHz external crystal
I will try with some other terminal software.

That probably won't help. PC's suffer the same problem of having a limited set of baud rates.
Not necessarily. Br@ys Terminal lets you specify any custom baud rate you want...

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

MartinM57 wrote:

Not necessarily. Br@ys Terminal lets you specify any custom baud rate you want...

Doesn't mean the OPs PC will support them though.

It's the same issue as the OP has. The baudrate generator is a divider string fed from a crystal oscillator. This limits the baud rates you can generate. If the crystal on the TX and RX have different values then there will only be a finite number of baud rates that are within a few % of each other.

As the rate goes up the problem gets worse because the divisor gets smaller and smaller.

PC baud rates are all based around 'proper' master oscillator values like 7.3728MHz.

Use a USB to serial converter and it gets a lot easier as your then often have fractional dividers to play with.

#1 Hardware Problem? https://www.avrfreaks.net/forum/...

#2 Hardware Problem? Read AVR042.

#3 All grounds are not created equal

#4 Have you proved your chip is running at xxMHz?

#5 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand."

Last Edited: Mon. Jan 9, 2012 - 05:23 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Interesting - thank you