cancel
Showing results for 
Search instead for 
Did you mean: 

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

JRich.7
Associate II

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.

1 ACCEPTED SOLUTION

Accepted Solutions

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".

View solution in original post

8 REPLIES 8
TDK
Guru

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

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

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

Yes it matches, doesn't change anything ​

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".
Piranha
Chief II

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

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

Thank you, this worked!