Skip to main content
JRich.7
Associate II
April 12, 2022
Solved

UART data corrupt when reading from terminal, how do I know whether my clock settings are correct?

  • April 12, 2022
  • 8 replies
  • 1868 views

I've written a simple program which should write data through UART to a PuTTY terminal on my laptop. I have the L4R5ZI Nucleo board, connected to my laptop via USB. I'm only sending 'Hello World \r\n' however, I get 'H9Go]oG #' back every time. All of the baud rate settings in the terminal are the same as my configuration, so I think it must be a clock error. I don't have an oscilloscope to check. Can anyone help? Thanks in advance.

This topic has been closed for replies.
Best answer by TDK

No, use PCLK1 or SYSCLK as the clock mux and use HSE bypass as the source for the PLL (or SYSCLK). The Nucleo board should output 8MHz to HSE bypass.

8 replies

TDK
April 12, 2022

The MSI is not very suitable as a clock source for UART, on account of its inaccuracy.

0693W00000LxlXAQAZ.png 

If you have no means to calibrate this and choose an appropriate MSICalibrationValue, using the provided HSE bypass clock source would be better choice.

"If you feel a post has answered your question, please click ""Accept as Solution""."
JRich.7
JRich.7Author
Associate II
April 12, 2022

0693W00000LxlYvQAJ.pngDo you mean like this? I have the same issue when I use this setup.

TDK
TDKBest answer
April 12, 2022

No, use PCLK1 or SYSCLK as the clock mux and use HSE bypass as the source for the PLL (or SYSCLK). The Nucleo board should output 8MHz to HSE bypass.

"If you feel a post has answered your question, please click ""Accept as Solution""."
JRich.7
JRich.7Author
Associate II
April 13, 2022

Thank you, this worked!

Tesla DeLorean
Guru
April 12, 2022

Some reason to use 7-bit rather the 8-bit? Terminal configured to match?

hlpuart1.Init.WordLength = UART_WORDLENGTH_7B;

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
JRich.7
JRich.7Author
Associate II
April 12, 2022

Yes it matches, doesn't change anything ​

Tesla DeLorean
Guru
April 12, 2022

Does the HAL_UART_Init return an ERROR?

If you unpack the LPUART1->BRR does the math work for the baud rate?

Board jumpered for low voltage VDDIO ?

NUCLEO-L4R5ZI 

or

NUCLEO-L4R5ZI-P ??

Engineer buys a scope...

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Piranha
Principal III
April 12, 2022

Get the typical 115200/8-N-1 working and only then try unpopular options.