cancel
Showing results for 
Search instead for 
Did you mean: 

baudrate generation on stm32f4

Sietse
Associate III
Posted on October 07, 2014 at 13:37

Hi list,

page 932 of the reference manual gives a formula to calculate USARTDIV.

But if I check the first entry in table 133 I get completely different values.

With Pclk=8MHz I get 8.10^6/(16*1200)=14.7, while the table says 416.6875.

I also have a working system that uses 115200 as baudrate, and if I do

 printf('' pclk1 %d en BRR %x\r\n'', RCC_ClocksStatus.PCLK1_Frequency, USART2->BRR);

I get

Pclk = 42MHz and BRR = 0x1117.

And 42.10^6/(16*273.44) = 1272654.6

Completely different from 115200

What am I doing wrong?

     Sietse

2 REPLIES 2
Posted on October 07, 2014 at 14:13

With Pclk=8MHz I get 8.10^6/(16*1200)=14.7, while the table says 416.6875.

 

What am I doing wrong?

Here apparently the math. The notation is rather awkward

8000000 /  (16 * 1200) = 416.6667

The 416.6875 comes from the truncation of the fractional portion to 4-bits.

ie  int((416.6667 * 16.0) + 0.5) / 16.0

6667 / 16 = 416.6875

Where 8000000 / 1200 = 6666.6667, and 6667 -> 0x1A0B

and 42000000 / 115200 = 364.5833, and 365 -> 0x16D

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Sietse
Associate III
Posted on October 08, 2014 at 09:14

D'OH!

I wrote . where I should have written *

Thanks!