115K Baud Rate with 16MHz Ext Crystal

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

Hello People,

 

Am working on a project that needs a high speed ( 57600 and above )  serial communication

 

My development environment is the Atmel Studion 6.2 (with VisualMicro plugin), AVRISP MKII Programmer,  

and Atmel Atmega328 MC with a 16MHz external crystal.

 

From the Device Programmer I set the SUT_CKSEL Fuse to EXTXOSC_8MHZ_XX_16KCK_14CK_65MS ( 8Mhz was the highest I could find )

the visualmicro enables me to use my Arduino code development background

 

Am trying to communicate with a ESP8266 Wifi module via  serial, when I try at anything above 19200 bps  it fails,

using an FTDI Cable I could communicate with the wifi module at 115200 bps so I know it not the modules limitation 

 

I know Arduino boards with Atmega328 can do serial at 115200 bps so why can't I do same?

Am I missing something or is there any other setting I need to set on the Device programmer

 

What is the highest reliable baud rate I can do with 3.3v powered Atmega328 running at 16MHz Ext Crystal?

 

Thanks for any insight 

 

Darl

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

Firstly, welcome to AVRFreaks.

 

Next, the Mega328 is not specified by Atmel to run at 16MHz when powered at 3.3 volts.

 

Also errors in matching to specific baud rates are related to the actual crystal frequency being used. Here is one table that lists typical errors. Reliable communications can be achieved if the errors are less than about 2%. There are "magic" crystal frequencies which result in zero% errors. These are whole multiples of 1.8432MHz.

 

Lastly, I suspect that your selection of fuse settings may be in error. The fuse calculator (eg http://www.engbedded.com/fusecalc/ ) does not list 16MHz specifically. Instead it says "8.0-MHz" where the "-" portion can be read as "and above".

 

Lastly, because of the above, if an Arduino is using a 16MHz crystal, it will be running at 5 volts.

 

Hope that helps a little.

 

Cheers,

 

Ross

 

Ross McKenzie ValuSoft Melbourne Australia

Last Edited: Sat. Feb 7, 2015 - 12:26 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Darl wrote:

Am trying to communicate with a ESP8266 Wifi module via  serial, when I try at anything above 19200 bps  it fails,

using an FTDI Cable I could communicate with the wifi module at 115200 bps so I know it not the modules limitation 

 

Sometimes, you just have to use a Baud rate Xtal :)

 

As mentioned, 16MHz and 3v3 is marginal on the curve, 14.7456MHz is still just above the curve, but less so.

 

If you have a FTDI cable, vary the Baud rate to see what your Module can tolerate. (FTDI devices have a virtual Baud frequency of 12Mhz ie that means they can do BaudV = 12MHz/N )

 

You can also transmit continual "U" on your MCU, and use a frequency counter to check what Baud you really have.

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

If I understand what Valusoft and Who-me is saying, it that with 3v3 I can't clock the Mega328 @ 16Mhz and as shuch can't have a baud rate as hingh as 115.2K bps ?

 

I just replaced the 16MHz crystal with 8MHz crystal and the best reliable baud rate I could get is 19200 bps,

so I guess my question now is, Is that the best rate I can get with 8Mhz Crystal?

 

If so then I guess I'll use a 5v @ 16MHz and a level converter btw the uC and the module provider I can get up to 115.2 Kbps

Darl

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

The table above indicates that with an 8MHz crystal you should be able to use 38.4K with the same error rate as 19.2K.  And with an 11.0592MHz crystal, which should work at 3V3, you should be able to work at 115.2K.

 

Cheers,

 

Ross

Ross McKenzie ValuSoft Melbourne Australia

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

I know Arduino boards with Atmega328 can do serial at 115200 bps so why can't I do same?

0) The arduino runs at 16MHz

1) The arduino uses the "double rate" setting of the BRG (U2X0 bit), because that results in a more accurate rate.

2) The arduino still runs with a 2.1% error, which is "marginal."

3) The avr on the arduino typically talks to ANOTHER AVR that does the USB serial conversion, that has the same error in the same direction.

 

Arduinos will also run at 1Mbps (accurately!) ( http://forum.arduino.cc/index.ph... )

The 11.0592MHz crystal is a fine idea.

If you are intent on using the internal oscillator rather than an external crystal, you MIGHT be able to recalibrate the internal oscillator that high (or to 9.216MHz, which also yields zero error at 115200)   According to the datasheet, the range allowed by OSCCAL ranges from about 4Mhz to over 12MHz.

 

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

Am actually using an external crystal, I understanding the internal oscillator have some accuracy issue 

Darl

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

Here's an expansion on Ross' serial error vs. oscillator frequency table.  Color coded to show when the baud rate is outside the RS232 standard for a given crystal.  With a 16MHz crystal, 57600 (2.1%) and 115200 (3.7%) are marginal baud rates.  An 18.432MHz crystal will give you perfect standard baud rates.

Attachment(s): 

Cheers,

Tom