## how to calculate ubrrl

8 posts / 0 new
Author
Message

hi everybody,
i have to calculate ubrrl, when ubrr is above 256. their was a special formula for it. im searching on many forums for 1 hour now. i found nothing. and what was the max. for ubrrh 256 or 255?

greetings,

Greetings and welcome to AVR Freaks!

This is a standard-issue "fundamentals" question.

For UBRR values from 0 to 255, UBRRH = 0 (or 0x00, same thing) and the entire value is held in URBBL. That is because 255 = 0xff which just fits into 8 bits.

For larger values, some "overflows" into UBRRH.

The common wisdom is just forget about high and low registers if you are using C and write UBRR = value; the compiler will automatically put the necessary parts in the proper places.

Same goes for 16 bit timer registers and the value generated by the ADC.

By the way, do you have this in the correct forum? Is this really about xMega?

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Sat. Dec 21, 2019 - 11:53 PM

To use the UBRR formula, we need to know your AVR device type, your AVR system clock speed, and your desired baud rate.

thank you for your responds, its xmega32 and i need timer 1 and timer 0. and forgive my typo i meant ubrrh. i need to know how to calculate ubrrh the baud and systemclockspeed may can change but lets say 14400 Baud and 10MHz speed.

Last Edited: Tue. Dec 24, 2019 - 05:43 PM

jewlord wrote:
... its xmega32 ...

Atmel AVR XMEGA E Manual

[page 290]

21.10 Fractional Baud Rate Generation

due to

AVR1307: Using the XMEGA USART

[page 4]

2.1.3 Baud rate selection

"Dare to be naïve." - Buckminster Fuller

thank you for your respond. i know ubrr for bsacle=0 for u2x=0 is systemclockspeed/(16*baud) -1 and for u2x=1 it is systemclockspeed/(8*baud) -1. and if the value is over 255 (if i remember correctly) you had to subtract the value with 255 and the you had to use a formula. but i cant find the formula anywhere. i may have to calculate it during my exam, otherwise the excel table is good too. i apologize for all the circumstances :D

The formula  SHOULD be in the two references that gchapman provided. See Eqn 2.1 of the second reference. It tells you all you need.

What appears to be the problem, here, is the inability to grasp using two registers to hold a 16 bit value (well, 12 bits in this case). Methinks you need to get those fundamentals under your control, first.

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

Last Edited: Tue. Dec 24, 2019 - 09:56 PM