zhc
zhc

Reputation: 13

Why the data received by HAL_UART_Receive_IT() is not correct?

I am trying to use STM32f407 to receive a char from Rpi4. And I use the function-HAL_UART_Receive_IT() to receive data transmitted from Rpi4, while my Rpi4 use the function included from <wiringSerial.h>, serialPutchar(). However, when I deliver 48 in decimal ('0' in ascii code) from Rpi4, the data received in my STM32 is 252 in decimal. Could someone tell me how to solve it? Thank you all very much!

Upvotes: 0

Views: 665

Answers (2)

Benasking7124
Benasking7124

Reputation: 94

You might want to check the clock configuration of stm32. I've encountered a similar situation that I set the wrong clock frequency.

The SYSCLK should be 168 MHz, and the APB1 frequency should be 42 MHz.

Upvotes: 0

Damiano
Damiano

Reputation: 716

Double check serial configuration on both sides (Polarity, bitrate, stopbit, parity... etc), if this is not enough check the trasmission with a scope and verify that what's on the line correspond to expected settings.

Upvotes: 1

Related Questions