cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 not receiving properly from Arduino using UART

pari
Associate

 

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.

1 REPLY 1
Andrew Neil
Super User

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.

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.