2024-05-14 02:06 PM
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.
2024-05-14 02:30 PM
This tutorial shows how to receive and transmit using DMA with idle.
https://github.com/karlyamashita/Nucleo-G431RB_Three_UART
2024-05-14 02:38 PM
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?
2024-05-14 02:43 PM
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.