2025-07-29 6:13 AM - last edited on 2025-07-29 6:27 AM by Andrew Neil
I'm implementing UART communication between an Arduino Uno and an STM32L476RG. When the STM32 acts as the master (transmitter) and the Arduino Uno as the slave (receiver), data transmission works as expected. However, when I reverse the roles—making the STM32L476RG the slave (receiver) and the Arduino Uno the master (transmitter)—the STM32 fails to receive data correctly. I'm looking for a reliable solution to ensure proper UART communication in this configuration.
2025-07-29 6:25 AM - edited 2025-07-30 1:49 AM
Welcome to the forum.
Please see How to write your question to maximize your chances to find a solution for best results.
In particular, please give details of your hardware, your code, and what tools you're using.
@pari wrote:the STM32 fails to receive data correctly. .
What does that mean, exactly: it receives nothing? receives junk? receives partial data? other?
How are you sure that your Arduino is transmitting correctly?
It's generally better to test against a terminal on a PC - then you remove all the unknowns of your code on the Arduino.
@pari wrote:I'm looking for a reliable solution to ensure proper UART communication in this configuration.
A common approach is to have the UART receive under interrupt to a ring buffer, and your main loop processes the data from that buffer. (this is what the Arduino does internally).
PS:
There's a bit more detail here of how the Arduino Serial works "under the hood" - including use of interrupts & ring buffers.