Skip to main content
stm32lover
Associate
February 27, 2019
Solved

STM32F103C8 UART cannot receive correct data by another same MCU

  • February 27, 2019
  • 2 replies
  • 1238 views

Thank you in advance.

I am trying use two stm32f103c8t6 to do communication stuff. One is used to be transmitter and another is receiver. The code is simple but it doesn't work.

Source code as follows:

Transmitter:

while (1)

{

uint8_t tran[4] = {0x21, 0x48, 0x59, 0x00};

  HAL_UART_Transmit(&huart1, tran, 4, 10);

HAL_Delay(100);

}

Receiver:

while (1)

{

HAL_UART_Receive(&huart1, tran, 4, 10);

HAL_Delay(100);

 }

The baud rate is set to 115200 bits/s. I use usb-to-ttl to check the situation. The transmitter is working normally, but the receiver cannot receive the normal data as expected.

Please help!!!

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

Hi,

please check if both MCUs have common ground.

Regards,

2 replies

After Forever
Senior III
February 27, 2019

The sending and receiving aren't synchronized. Transmitter sends the 4 bytes (it takes very little time) while most likely (~90%) the receiver is in HAL_Delay(100).

stm32lover
Associate
February 27, 2019

Thank you for replying. I just try this. Although I can receive some data, those data are some strange/ wrong data.

mh_stm
mh_stmBest answer
Associate II
February 27, 2019

Hi,

please check if both MCUs have common ground.

Regards,

stm32lover
Associate
February 27, 2019

Thank a lot. This helps me to finish my whole day work