2014-10-07 04:37 AM
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? Sietse2014-10-07 05:13 AM
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 awkward8000000 / (16 * 1200) = 416.6667The 416.6875 comes from the truncation of the fractional portion to 4-bits.ie int((416.6667 * 16.0) + 0.5) / 16.06667 / 16 = 416.6875Where 8000000 / 1200 = 6666.6667, and 6667 -> 0x1A0Band 42000000 / 115200 = 364.5833, and 365 -> 0x16D
2014-10-08 12:14 AM
D'OH!
I wrote . where I should have written * Thanks!