cancel
Showing results for 
Search instead for 
Did you mean: 

usart baud rate

sanaz
Associate II
Posted on June 30, 2016 at 12:38

hi

i wanna connect stm32f407discovery board to stm32f429 via uart communication. how can I calculate the closest baud rate to 5Mbps for these 2 board? I use following cod and it work but I want to be sure about minimum Error bit:

    USART_InitStruct.USART_BaudRate = 5000000;

    USART_InitStruct.USART_HardwareFlowControl =       USART_HardwareFlowControl_None;

    USART_InitStruct.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;

    USART_InitStruct.USART_Parity = USART_Parity_No;

    USART_InitStruct.USART_StopBits = USART_StopBits_1;

    USART_InitStruct.USART_WordLength = USART_WordLength_8b;

    USART_Init(USART1, &USART_InitStruct);

  USART_Cmd(USART1, ENABLE);

2 REPLIES 2
Nesrine M_O
Lead II
Posted on June 30, 2016 at 13:56

Hi sanaz,

Please have a look to the Fractional baud rate generation paragraph in the USART section in your related reference manual to have idea on how the USARTx_BRR register is programmed and about the error calculation for programmed baud rates.

-Syrine-

Posted on June 30, 2016 at 14:52

5Mbps is awfully high for such an interface.

I'd divide the 5 MHz into the APB clock, create an integer and then divide that into the the APB clock, and then do a percentage of that vs the original 5,000,000 You could check that the BRR matches the number you got.

The STM32 is going to favour clean division. so a 180 MHz CPU with a 90 or 45 MHz APB is going to do a lot better than a 168, 84, 42 one. I'd tend to pick system clocks that favour the outcome I want, so running the part at 160 MHz might be preferable, though it would preclude USB without a PHY

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..