cancel
Showing results for 
Search instead for 
Did you mean: 

BAUD RATE CALCULATION FOR USART IN STM32

MMoba.1
Associate

PLEASE EXPLAIN WHY 104.167 IS CONVERTED TO 104.1875 AND HOW ITS ENCODED AS 0X683

MY UNDERSTANDING FOR ENCODING IS 104 IS CONVERTED TO HEX AS MANTISSA PART AS DECIMAL TO HEX AND O.1875 IS CONVERTED SEPARATELY FOR FRACTION PART.

IF I USE FCLK/BAUDRATE I.E 16MHZ/9600= 1666.666d =1667d=0x683h

why use above formula i don't understand.

0693W000004IhA6QAK.jpg

12 REPLIES 12

I'm understanding now the calculation of the mantissa and fraction and with that the baudrate when it's 16x oversampling.

I guess now that the calculation formula for 8x oversampling is the following:

 

BAUD = fCK / (8 * USARTDIV) ? (And not (16 * USARTDIV))

Am I right with this

And is there any reason for change the oversampling rate?

Yes.

> And is there any reason for change the oversampling rate?

In the extreme case of very low AHB/APB clock, you can achieve higher baudrates, at the cost of somewhat lower baud mismatch immunity.

JW

In the documentation stands something about, if the fraction is too big for the 4 bits then the "carry" must be added to the mantissa.

Screenshot 2024-07-10 at 08.24.17.png

But I don´t understand what the "carry" of 0d0.99 is? Because they simply round up the 0d50.990 to 0d51. :thinking_face: