2022-06-25 04:56 PM
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)For 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.
Solved! Go to Solution.
2022-06-26 11:24 AM
>> 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
2022-06-25 06:01 PM
No idea what you're describing
For 16x Oversampling Mode
BRR = APBxClock / Baud
Say USART1, on APB2, with a clock of 24 MHz
24,000,000 / 115,200 = 208.3333 -> 208
2022-06-25 06:32 PM
USARTDIV=fclock / (16*baud)
USARTDIV=24000000/(16*115200)==13
And what is this number 13?
In this case, the USART_BRR register will be written to the number 13 0
HEX:D0
Decimal: 208
What is this number 208? I do not understand.
This number is similar to the number of samples for each bit at the specified baud rate of 115200
2022-06-25 07:16 PM
---
2022-06-25 07:16 PM
---
2022-06-25 07:56 PM
It looks like DIV_Mantissa contains the speed required to transfer the entire data packet.
For example: 24000000/(16*115200)==13.02083
The data transfer rate of 13 baud is necessary in order for the entire data packet of 115200 bits * 16 sampling to be transmitted in one bit at this rate. 115200*16==1 843 200
24000000/13.02083==1,843,200
And I still did not understand how to apply the number 208.
What is this number?
If we divide 208/13.02083==16
Then you can get sampling, maybe in order to divide the packet within one bit at a speed of 13 baud, into 115200 bits.
So 208 is not a baud rate.
Baud rate is 13.02083
And 208 is entered into the USART_BRR register because the last 4 bits of this register are for the fractional part.
Just such a form of recording in this register.
The actual baud rate is 13.02083
2022-06-25 09:42 PM
I think the number 16 in the formula is to combine the integer and fractional parts in one register.
This trick works only with the number 16.
I didn't manage to do it with other numbers.
2022-06-26 12:15 AM
That's an old problem with STM32 Reference Manuals. Just forget this "division by 16" and "fractional part" and everything becomes simple. For 16x oversampling (default), the value in BRR should be the properly rounded result of dividing the UART input clock by the baud rate. That's it. No "fractions", no "div by 16".
It is almost the same in 8x oversampling mode. The only difference is bit 3 of BRR is not used and the result of division is written to bits 15..4 and 2..0.
Also, see this link:
2022-06-26 12:25 AM
24,000,000 / 115,200 = 208
Number 208 What is it?
It's not the baud rate.
The baud rate is 13 baud.
24000000/16*115200==13
2022-06-26 12:49 AM
208 This is the number written in the entire register.
In DIV_Mantissa 13 is written. This is HEX==D
In DIV_Fraction 0 is written
All together this is HEX== D0
In decimal it is 208
And the data transfer rate is not 208, but 13