Showing results for 
Search instead for 
Did you mean: 

STM32 receiving and transmitting data at the same time

Associate II



Hello, I am new to the stm32 world.

I'm trying to use my stm32f103c8t6 board as an intermediary to enable communication between the computer and arduino.

The project is simply based on receiving a message from the computer, and the STM32 sending a different message package to Arduino according to the incoming message.

That is, receive and transmit operations must occur simultaneously.

For this, at first I was receiving data via USB CDC and transmitting data via UART and I was successful. But for reasons beyond my control, I need to use a communication method other than USB-CDC.

Even though I tried to use uart for data exchange, I was not successful, there is an example code I shared at the image (pink ones are message I sent, black ones message I get) I would appreciate it if you could tell me the changes I should make for this process or the protocols you recommend me to use.



Karl Yamashita
Lead II

This tutorial shows how to receive and transmit using DMA with idle.

Try to avoid blocking functions like HAL_UART_Transmit() in interrupt / call-back context.

Buffer all incoming data and don't create dependency on a single buffer and synchronization of the first byte.

Your reception pattern is not intuitive and your input demo doesn't really convey what it's supposed to do vs what it's actually doing.

It's receiving 6 bytes? Looking for a S****F* pattern? Is it supposed to resynchronize?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Message packets from the computers serial terminal to the stm32 are in 5-digit SXXXF (e.g. S123F) format. What the stm32 needs to do is to transmit the only 4th digit of the message to the next device (in this case, Arduino). I also tried using the HAL_UART_Transmit_IT function, but this time no data was transmitted.