cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F103C8 UART cannot receive correct data by another same MCU

stm32lover
Associate II

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!!!

1 ACCEPTED SOLUTION

Accepted Solutions
mh_stm
Associate II

Hi,

please check if both MCUs have common ground.

Regards,

View solution in original post

4 REPLIES 4

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

mh_stm
Associate II

Hi,

please check if both MCUs have common ground.

Regards,

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

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