cancel
Showing results for 
Search instead for 
Did you mean: 

What is written to the USART_BRR register?

MMust.5
Senior II

What is this value that is written to the USART_BRR register?

What is it for?

I don’t understand why the calculation is done using the formula: fclock / (the divisor, in my formula it is 5 * baudrate)0693W00000NskeHQAR.pngFor example, here is an example calculation:

I made the numbers much smaller to simplify the example.

fclock / (divisor, in my formula it is 5*baudrate)

fclock ==Clock frequency==30 Hertz.

Desired baudrate==2

Divisor == 5

30 fclock / 2 baud * 5 divisor==3 this number is written to the USART_BRR register.

3 what is this number?

What is it for?

BRR== Baud Rate Register. But 3 is not the baudrate I needed. I have 2 desired baudrate.

Or does it not matter what my desired data rate is?

Why would I then enter the desired baud rate if that's the case?

Does this formula calculate the speed that will be applied, and not the speed that I need?

-----------------------------------

Maybe this will be useful: Shown in the picture

If a marker is set every 3 bits at a clock frequency of 30 Hertz, based on these markers, we get a speed of 10 baud.

But I needed a speed of 2 baud, this formula: fclock / (divisor, in my formula it is 5 * baudrate) does not produce this calculation.

18 REPLIES 18
gbm
Lead III

115200 is the baud rate; UART_CLOCK / BAUD _RATE (correctly rounded) is the value written to BRR register. BRR is a baud rate divisor register. That's it. Forget "mantissa" and "fraction". UART input clock divided by BRR content gives the baud rate.

>> Number 208 What is it? It's not the baud rate.

USART1->BRR = 208

Like I said BRR = APBxClock / Baud

The logic doesn't do math, it is a counter, acting as a divider. This is relatively simple to do with logic gates, and thus transistors. The UART doesn't have any code running inside it, it is a machine.

The 16x over-sampling matches well with the 4-bit fractional model

The BRR is NOT the baud rate

Baud Rate = APBxCLK / USARTx->BRR

Baud Rate =24,000,000 / 208

Baud Rate = 115384.62 ie 115200 +0.16%

BBR = 2500

24,000,000 / 2500

9600 baud

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Consider the oversampling, which normally is 16. 13*16 = 208

I don't understand.

Still, the number 13 is stored in the USARTx->BRR register?

And this number for the desired sampling is multiplied by 16 or 8?

13*16==208

13*8==104

24000000/208==115 384

24000000/104==230 769

This formula contradicts what you wrote:

0693W00000NsnGSQAZ.pngUSARTDIV is not 208.

USARTDIV is 13.

This is the correct formula:

24000000/16*115200==13

---------------------

208 decimal form of the HEX number that is stored in the BRR register: D0

D==13

0==this is the fractional part of USARTDIV equal to zero.

You wrote:

>>Baud Rate =24,000,000 / 208

The number 208 will only be when discretizing 16.

But first you need to find out what the divisor will be.

208 will be in the BRR register both at sampling 8 and at sampling 16, but this does not mean that you must always divide by 208:

24000000/208 is wrong to always divide by 208, first you need to find out what discretization will be.

First you need to find the USARTDIV divisor.

This is done like this:

24000000/16*115200==13 For baud rate 115200.

The bit rate at sampling 8 will be 230,400

24000000/13*8==230400

This is how the divisor is calculated for a rate of 230,400 and a sampling rate of 8:

24000000/8*230 400=13

That is, the USARTDIV divisor is the same in both cases.

The number 208 is not 208.

This is D0 in HEX

It's 13

13 is the number to be multiplied by the desired discretization: 8 or 16

So I think it's clearer.

I thought and still I don’t understand why the formula uses division by 16.

fclock / (16*baudrate)

Everything that follows is clear, but why division by 16 is used in the formula is not clear.

Seems to understand.

So it is very convenient to find the desired divisor.

As I described above.

If there were no division by 16 in the formula, then the number 208 would be written into the BRR register.

And how now to find the divisor for sampling 8? 208/2? Illogical calculation.

13*16

13*8

So much clearer.