[En-Nut-Discussion] Baud rate question

Thiago A. Corrêa thiago.correa at gmail.com
Wed Mar 25 20:41:44 CET 2009


Hi Konrad,

On Wed, Mar 25, 2009 at 4:03 PM, Konrad Eisele <eiselekd at gmx.de> wrote:
> u_long baud = 9600;
> _ioctl(_fileno(uart), UART_SETSPEED, &baud);
> ..

Yes, looks good.

> Im periodically writing out a simple string in ehternut,
> inside minicom I can now see that some garbage is
> periodically apearing. That suggests that the
> baud rate is not configured corectly. So
> my question is:
>
> What are the correct values to UBRR0
> I have added
> NUT_CPU_FREQ = "1000000"
> NUT_DELAYLOOPS = "1000"

The atmega128 datasheet has a table with some clock values per
baudrate that gives UBRR0 values and their error margin.

Every now and them I also struggle with that same problem whenever we
do a new project. The most often cause is wrong fuse settings, some
settings like CLKOPT messes up with the meaning of the other bits.

Since you are running out of internal clock, did you calibrate it?
Been there, done that... problems with the calibration value can have
you chasing bugs for a week :(
AVRStudio + a jtag mkII can give you the calibration value, but it's
up to you to figure how to initialize it. Note that this value is
somewhat silicon specific and you will need to calibrate every device
you produce.
There is an auto calibration routine on Atmel website if you want to
try that but it requires an external reference crystal. It's used on
the Raven Kit.

> to my ethernut configuration. Id like to use the 9600
> baud rate. It shold be slow enough for a 1mhz configuration,
> or am I wrong?

If I'm not mistaken faster clocks are less error prone than slower
clocks. It's crazy, but has to do with the divider. The datasheet
tables will give you a clear picture.

Hope this helps.

Kind Regards,
   Thiago A. Correa



More information about the En-Nut-Discussion mailing list