2019-02-27 03:05 AM
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!!!
Solved! Go to Solution.
2019-02-27 03:14 AM
2019-02-27 03:14 AM
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).
2019-02-27 03:14 AM
Hi,
please check if both MCUs have common ground.
Regards,
2019-02-27 03:17 AM
Thank you for replying. I just try this. Although I can receive some data, those data are some strange/ wrong data.
2019-02-27 03:53 AM
Thank a lot. This helps me to finish my whole day work