baudrate generation on stm32f4
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-10-07 4:37 AM
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
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-10-07 5:13 AM
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 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
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2014-10-08 12:14 AM
Posted on October 08, 2014 at 09:14
D'OH!
I wrote . where I should have written * Thanks!