Search code examples
raspberry-piserial-portstm32

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!


Solution

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