cancel
Showing results for 
Search instead for 
Did you mean: 

Help with understanding UART interface

mdiro
Associate III

I have a device made of two modules. Each module has its own ST microcontroller, family is STM32L476. They are connected together with a cable of 2-2.5 meter coated, most likely, with a silicone tube.

I need to make the two microcontrollers communicate with each other and I do not expect a frequency higher than 10kHz. UART would be the easiest choice but I am a bit confused.

Do I need to add any other physical IC interface for making the MCU communicate with each other or the MCUs already have an embedded interface and so connecting the UART/USART pins via 2 cables is enough? I imagine TX1 pin->RX1 pin and TX2 pin ->RX2 pin.

Thank you 🙂

9 REPLIES 9
Kamil Duljas
Senior III

Of course. All STM32 have UART interface and what you need is configure UART on each board. Yes, you need only 2 wires 🙂

Dudo

Thank you for your reply :). So you think that just using the 2 wires, 2-3 meters long, does not affect the signal integrity?

Kamil Duljas
Senior III
LCE
Principal

Directly connecting the MCU IOs over a few meters is a good way to kill stuff - unless it's really in controlled lab only, but even then:

ESD, wrong cabling / connectors, ground loops, ...

So you should at least provide some protection (resistor + diode minimum), I would prefer some real IO drivers plus protection, which could be easier replaced in case of damage than the STM32.

mdiro
Associate III

Thank you for your answer. So, if I understood correctly, you would use something like RS-232 Interface IC in both boards? FYI, the 2 boards will be within 2 enclosures and "only" the cable will be exposed. 

That would depend on the actual cable length.

If it's only for lab use and only a few meters, even some 3.3V line driver would be good enough, it doesn't need to be an RS232 IF - on the other hand, these are cheap and don't have too many pins.

Just don't connect the MCUs directly.

And "only" the cable... no connectors?

And are you sure there will be no ground loop? Think about where the power supply for each board comes from, even different mains wall socket in the same room might cause trouble, depending on what else is supplied.

gbm
Lead III

You need 3 wires, not 2. Ground must be connected, too. Other than that - it will surely work in the lab or on your desk, but not necessarily in a noisy environment. For real world applications, use RS232 or RS485 transceivers.

I support the differential idea, using RS485 transceivers.

+1 on RS232 usage, would provide some protection on the pins/connectivity.

Many of the transceivers can support to 1 Mbps rates, depends on capacitors/specifications.

Some transceivers also can provide a signal to indicate if the cable is attached, or not, and an enable pin to save power.

+1 on Ground loops and related issues. Differential pairs might be appropriate.

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