uracoli-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [uracoli-devel] error in UART baudrate?


From: Axel Wachtler
Subject: Re: [uracoli-devel] error in UART baudrate?
Date: Fri, 19 Dec 2014 21:31:07 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

Hi Tomás,

I just tried 250kbps/16MHz on Radiofaro - together with a python terminal (sterm.py) it worked. However this was with the current Mercurial version, but with the last release 0.4.2, I failed the same way like you. (250kbs fit better to the 16MHz).

I could not yet find the code change that is causing the repair,
some lines in hif_uart.h had changed ... but they need some review.

If you don't want to start with scons, I can roll you a package from the current snapshot.

Next release needs some more time, we added some sensor stuff to the
lib, that is not yet completely documented.

Cheers, Axel.


Am 19.12.2014 um 14:13 schrieb Axel Wachtler:
Just a short response, ... for testing the UART, you can use xmpl_hif.c,
with 16MHz and Megarfa1 the rate 57600bps is proven and tested.
Having this running will be a solid starting point before pushing it
more to the limit.
As for uint16_t br in HIF_UART_INIT: br is not the baudrate, br is the
value for the UBRRxH and  UBRRxL register. According to the data sheet
the value for UBRR (br) has a range of 0 ... 4095 - the higher values it
gets for lower baud rates.
In the code the MSB of br is set, if U2X is used, that bit is masked out
before writing UBRR.
Let's hear, how it goes with the UART and standard baudrates on your
project.
Cheers, Axel.
.
*Gesendet:* Freitag, 19. Dezember 2014 um 12:05 Uhr
*Von:* "Tomás Ángel Glaría López" <address@hidden>
*An:* "Axel Wachtler" <address@hidden>
*Betreff:* RE: [uracoli-devel] error in UART baudrate?
Yes, im aware that both values of baudrate (65535 and 65536) calculate
the same number after the encode_baudrate macro, what I meant with that
is for you to see the difference with a 16bit value and a 32bit one.

The problem lies, according to me, that when you call the macro inside
the function, the baudrate variable is a 16bit variable so the value
65535 is 0xffff and the value 65536 is 0x0000 (should be 0x10000 but
it's truncated). If all worked ok, then the encoded values would be the
same for both numbers, but it isn't. With the first one I can
communicate with the serial port, with the second I can't (o rather I
haven't found the baudrate at which the mcu is communicating).

According to my calculations, in a atmega128rfa1, when trying to use a
baudrate of 65535, the real baudrate is 66,666.6666666bps.
To test the communication, im coded a python script which is a serial
sniffer a lets me set any baudrate i want, im using an ftdi usb-serial
adapter between the pc and the mcu (i cant really test if i can get any
baudrate i want with the ftdi serial adapter, but i'm certainly able to
get more  no Standard values).

Hope that helps.

Also, the wibo bootloader serial communication isnt working fir me right
now, but I have onvestigate a little more before asking for help.

Bwst regards,
Tomás Glaría
------------------------------------------------------------------------
From: Axel Wachtler <address@hidden>
Sent: ‎19-‎12-‎2014 2:45
To: Tomás Ángel Glaría López <address@hidden>
Subject: Re: [uracoli-devel] error in UART baudrate?


Am 19.12.2014 um 03:45 schrieb Tomás Ángel Glaría López:
 > By the way, im using f_cpu=16000000ul.
 > Any baudrate value under 2^16 works (I tried with 65535 and it works,
 > with 65536, it doesn't work).

How do you test the none standard baudrates (65535/65536) from the host
/ PC site?

In the test programm, the ENCODE_BAUDRATE macro calculates the same
value for 65535 and 65536.

What I've seen with the macro is, that for 16MHz and 115200bps the ubrr
value is off by one from the value in the data sheet.

br=115200 f_cpu=16000000, encode_ubbr=7 u2x_ubrr=16 ubrr_value=7
--> should be 8.
br=76800 f_cpu=16000000, encode_ubbr=12 u2x_ubrr=25 ubrr_value=12
br=65535 f_cpu=16000000, encode_ubbr=14 u2x_ubrr=29 ubrr_value=14
br=65536 f_cpu=16000000, encode_ubbr=14 u2x_ubrr=29 ubrr_value=14

However, according to the datasheet, the baudrate error for address@hidden
is -3.5% or 2.7% with U2X, so with conventional hardware you will get
a high error rate ... thats why nobody had looked at it until now, so
I'm just wondering how your manual values do work.

Since it is a new board, can you double check the XTAL, if it is really
16MHz.

Axel.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]