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.