cancel
Showing results for 
Search instead for 
Did you mean: 

UART baudrate problem

Mohamed GORRAB
Associate II
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  

7 REPLIES 7
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 Venmo
Up vote any posts that you find helpful, it shows what's working..
Mohamed GORRAB
Associate II
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 !

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 Venmo
Up vote any posts that you find helpful, it shows what's working..
henry.dick
Senior II
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.

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,

Posted on April 09, 2018 at 19:00

I tend to print out the value of SystemCoreClock along with the AHB, APB1 and APB2 clock speeds when my systems start, it helps when testing code across a wide range of STM32 part families.

You could look at the library code computing the setting.

If would avoid keeping such a Watch/View open as it will break the USART functionality

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on April 10, 2018 at 14:03

Turvey.Clive.002

‌,

henry.****

Hi, the problem is not solved, below is the clock configuration,

0690X0000060AW6QAM.png

Based on the figure above,

I tried to use the different divisions /1, /8.. and the different clk (PPLCK, SYCLK, HSE...) to obtain the correct frequency, but everytime, I have the some frequeny output that I showed on the scope,

HSI --> 16MHZ (correct value)

SYSCLK --> 32MHZ (wrong value != 10 MHZ)

PLLCLK -->

32MHZ (wrong value != 10 MHZ)

.....

I added some instructions on the code to show the frequency value, and that gives 32MHZ as shown on the pictures below

0690X0000060AWGQA2.png

0690X0000060AWBQA2.png

0690X0000060AWHQA2.png

Anyone have a solution please!

Thanks in advance!