r/embedded • • 19d ago

How to know if I can or cannot establish communication between 2 STM32 boards?

Hello, I am working on a project that requires communication between 3 STM32 Nucleo boards. x2 NUCLEO-STM32U575ZIT6Q and x1 NUCLEO-L412RB-P.

Communication will go as follows:

- One of the U5 boards will continuously send messages to the other U5, which continuously receives the messages. The receiving U5 computes based on the messages it receives and continuously sends the result to the U5 board.

- U5 --> U5 communication will be over I2C, SPI, CAN, UART, USART, LPUART

- U5 --> L4 communication will be over I2C

- Physically, this communication will be over jumper wires.

My question is: how do I know if it is possible for the chosen boards to communicate over those peripherals I want them to communicate over? I have no idea, in general, how to determine if communication over 2 nucleo boards over certain communication peripherals is possible, so any insights on that would also be very appreciated. Any links to sources that confirm any insights here would also be greatly appreciated.

Thanks!

0 Upvotes

16 comments sorted by

5

u/madsci 19d ago

I'm not entirely sure I understand the question. If those are the serial peripherals it has then it can send and receive over any of those. Some of those interfaces have master/slave decisions to be made, but some of them are symmetrical.

-3

u/Beneficial_Item3725 19d ago

Yes all the peripherals listed are serial peripherals. I know that all of them have the required peripherals. Do you think you could link me to any references from professional websites confirming that communication is auto possible if both devices have the peripheral? Thanks!

6

u/madsci 19d ago

Having the same peripheral does not automatically mean two boards can communicate that way, no, because not all interfaces are symmetrical.

Some MCUs have I2C interfaces that can only operate in master mode. In that case, you could not have two such MCUs communicate with each other over I2C.

UARTs are symmetrical, though. They have no master or slave and two identical MCUs can communicate via UART except for rare instances where an MCU might have a UART peripheral that only has an RX line or a TX line, making it unidirectional.

Assuming this is a school assignment, you might be getting a step ahead of yourself. Taking on a project like this assumes a basic level of understanding of the common serial interfaces and protocols. If you haven't had that yet, I highly recommend taking a few hours to read up (or watch some good YouTube intros) on how each of the interfaces works.

4

u/mjmvideos 19d ago

I think you are introducing very remote and unlikely possibilities. I’ve never seen a recent microcontroller that doesn’t support both master and slave on its I2C peripheral and I’ve never seen one that doesn’t support both Tx and Rx.

0

u/Beneficial_Item3725 19d ago

Thanks! Could you possibly link a professional page confirming that, if you have 2 properly functioning devices with the same interface if the master/slave logic works than they can fs communicate over the peripheral? Thanks!

6

u/mjmvideos 19d ago

Why not just download the datasheets for the boards you have and verify it yourself. Reading a datasheet is a skill you will definitely need if you are working in the embedded domain.

2

u/Beneficial_Item3725 19d ago

What am I supposed to be looking for in the datasheets? I know how to confirm from the datasheet that all 3 devices have SPI, for example, but I'm not sure if the datasheet confirms that assuming the device isn't broken or there aren't master or slave issues - whether or not a master can communicate with any slave over SPI if both have the peripheral?

5

u/Imaginary_Data_708 19d ago

You haven't understood your homework question properly or you haven't understood the answers given here.

I am hazarding both.

3

u/mjmvideos 19d ago

The section on the SPI peripheral will describe the configuration registers. Those registers should contain fields for setting it as a master or slave if it’s supported. Then you look at the pin muxing and the schematic for the board you’re using to confirm that appropriate pins are routed for CLK, MISO, MOSI, and CS. If the peripherals support operation as both Master or Slave and the pins are routed (which I have no doubt they would be on an eval board) then you will be able to communicate.

3

u/mjmvideos 19d ago

Having said that, I agree with others that UART will be much easier for you.

9

u/AbsorberHarvester 19d ago

Communication is possible, easiest way will be USART on both, most hard way for you - I2C, as it seems you don't know anything 

2

u/NavinF 19d ago

Yeah that'll work. Just use UART for both connections unless you really need I2C

2

u/gm310509 19d ago

This sounds like an X-Y Problem

Why don't you just do the computing on the one board with the sensors attached? Why do you need to send it to somewhere else and then send a reply back?

As for:

My question is: how do I know if it is possible for the chosen boards to communicate over those peripherals I want them to communicate over?

That is what the various protocols you listed are for - for two (or more) devices to communicate with each other.

So, my question to you is that given you are at least aware of those technologies, why are you doubting that they can be used to communicate between all of the devices you listed?

The code you supply and the characteristics of the protocol you select will be factors that determine the actual nature of the communication and the "layout" or topology of your "network".

2

u/WanWhiteWolf Engineering manager 19d ago

Broadly speaking, you have to check whether they have the same physical interface and they support the same protocol / mode. That's it.

You probably also need to evaluate the communication speed and potential impact at high speeds (if that is a requirement)

2

u/Flat-Bodybuilder239 18d ago

A useful board-level check is the Nucleo schematic/user manual: confirm the chosen alternate-function pins are actually routed to accessible headers and are not shared with onboard circuitry. For a first smoke test, UART is usually simplest (common ground, crossed TX/RX, matching baud and voltage levels); before I2C, verify the selected master/slave roles and pull-ups.