Skip to main content
Mohamed GORRAB
Associate II
April 8, 2018
Question

UART baudrate problem

  • April 8, 2018
  • 3 replies
  • 4121 views
Posted on April 08, 2018 at 20:15

Hello,

I try to send data via UART with a baudrate 8Mb/s using 

Nucleo-L476RG and UM232H,

the programs I use are 

STM32CubeMx and Putty (for RX)

As shown on the picture below we can send data

via

 USART1 

with a baudrate between 2.443Kbits/s and 10Mb/s 0690X0000060ATcQAM.png

but in reality when I exceed 1Mb/s ,I don't recieve any information in RX,

Probably, it is a speed interval problem generated in code as shown on the pictures below, I think, there is a bad coordination between the configuration and the code,

0690X0000060ATgQAM.png

 This is the declaration part :

0690X0000060AUFQA2.png

Can any one help me please!

Thanks in advance  

    This topic has been closed for replies.

    3 replies

    Tesla DeLorean
    Guru
    April 8, 2018
    Posted on April 08, 2018 at 20:25

    So does it throw a HAL_ERROR?

    If you take the USART BRR value what does that translate back to in terms of achieved baud rate?

    Does the USART indicate Rx errors?

    Please try not to create multiple threads for the USART topic

    https://community.st.com/0D50X00009XkWUGSA3

     
    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Mohamed GORRAB
    Associate II
    April 8, 2018
    Posted on April 08, 2018 at 20:33

    Hi, No there is no error in both of code and RX, but there is nothing in RX when I exceed 1Mb/s,  

    for the USART BRR it is between 0x10 (16 in hex) and 0xFFFF, and I use clk = 80MHz, so normaly the maximum of baudrate in this case in 80000000/16 = 5Mb/s !

    Tesla DeLorean
    Guru
    April 8, 2018
    Posted on April 08, 2018 at 20:42

    Ok, but what value is programmed into the BRR in the failure cases, and what rate does that compute back too?

    Have you looked at the signal with a scope or logic analyzer?

    Make sure not to view the peripheral registers in the debugger, read and decode the USART->ISR and output via SWV.

    Check for Noise and Framing Errors.

    Try doing a loop-back test for Tx / Rx at the selected rate, check that also with a scope.

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    Mohamed GORRAB
    Associate II
    April 9, 2018
    Posted on April 09, 2018 at 18:31

    Hi, in fact, I solved a part of the problem, I used HSI instead of MSI, and with this solution I can reach 4Mb/s, 

    The problem now is that BRR  is fixed all of the time at 16, Is there any solution for that, to obtain a maximum of baudrate!! 

    0690X0000060ARRQA2.png

    According to the expression below between BRR and Baudrate, we can obtain baudrate = 8000000/16 = 5Mb/s (Frequency fixed at 80MHz), but in reality we can reach only 4Mb/s and in this case I 

    looked at the signal with a scope and the baudrate was 4Mb/s, so is there a solution for these 2 problems : 

    1/ Why we can't exceed 4Mb/s! to reach logically 5Mb/s

    2/ How we can explain the confusion, We have BRR = 16, and baudrate = 4Mb/s so that give frequency = 64MHz which is different to 80MHz we entred in configuration

    0690X0000060AUjQAM.png

    Thanks in Advance,

    henry.dick
    Associate II
    April 9, 2018
    Posted on April 09, 2018 at 20:30

    Easy. 

    1. Go through the math as laid out in the data sheet and see what value the baud rate registers should have. And

    2. Step through your code and see what value the baud rate registers actually have.

    The fact that your code works at lower speeds tells you all you need to know about the problem.