cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F722 UART data error according to SYSCLK

LJinH.1
Associate II

Hi,

I use STM32F722 on a custom board for UART communication with an external sensor.

When using SYSCLK with the maximum clock of 216 MHz using HSI and PLL, UART data was lost 2~3 bytes when 250 bytes were transmitted at once during UART communication with an external sensor.

It was the same even if I changed the UART CLK.

​However, when SYSCLK was set to 140 MHz or lower, data was not lost regardless of UART CLK.

I tried the same using the NUCLEO-F722ZE board to use the proven hardware.

When tested by adding UART in the CubeMX default setting (HSE, SYSCLK 216) of the NUCLEO-F722ZE board, No data was lost.

And when HSI was set to divide PLL, CLK error was displayed.

0693W00000QKqyMQAT.png

When I ignored the error and generated the code, the same phenomenon as the custom board occurred(No data loss occurs when SYSCLK is used below 140).

Q1. What causes CLK error when setting SYSCLK using HSI and PLL in NUCLEO-F22ZE?

Q2. What is the correlation between SYSCLK and UART data error?

Thank you.​

4 REPLIES 4
Andrew Neil
Evangelist III

Were you using the same baud rate in both cases?

Was your code running at the same speed in both cases?

If your code is running "too fast" for the other device to keep up, that could explain why data is lost at SYSCLK = 216 MHz, but not SYSCLK = 140 MHz ... ?

Bob S
Principal

HSE (external crystal) is a much more accurate clock source than HSI. So I am not surprised that HSE on NUCLEO board worked at 216MHz. I suspect that the "clock error" you see in CubeMX when selecting HSI and generating 216MHz is that the 48MHz to the USB block is not within USB tolerances (if you disable the USB interface the error goes away).

What baud rate?

Is this "sending data from STM32 to your device" or "receiving from device into STM32"? I think it is "sending from STM32" but I'm not sure from your initial port.

If sending from STM32, how are you sending? HAL_UART_Transmit()? HAL_UART_Transmit_IT()? HAL_UART_Transmit_DMA()? Or your own custom code?

Thank you for reply,

Both cases were run at the same baud rate(115200bps) and at the same speed in my code.

I sent data every 1 second after the code was executed, but when SYSCLK=216MHz, loss occurred in all data.

As you mentioned, I will test it to wait long enough for the other device to send data.​

Thanks for the info on the Clock error.

The baudrate was 115200bps.

I send data to an external device, and the external device echoes the received data + response message.

I used my own custom code for the transmission method, but data loss occurred, so I also used HAL_UART_Transmit() / HAL_UART_Receive(), but the result was the same.