Data transmission between 2 STM32 microcontrollers

For general Flowcode discussion that does not belong in the other sections.
Post Reply
OderlandoRSilva
Posts: 36
http://meble-kuchenne.info.pl
Joined: Mon Oct 30, 2023 1:17 pm
Has thanked: 3 times
Been thanked: 5 times

Data transmission between 2 STM32 microcontrollers

Post by OderlandoRSilva »

Hello everyone.
I want to communicate between 2 STM32 microcontrollers and I'm having some difficulties doing so.
At first, I don't think I know the correct way to do this.
What tool should I use for this? UART? (CAL or RS232?), SPI?
I apologize for my many doubts.

chipfryer27
Valued Contributor
Posts: 1685
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: Data transmission between 2 STM32 microcontrollers

Post by chipfryer27 »

Hi

Although I'm not too familiar with STM products it should not be too difficult to do as you require.

First thing I'd consider is the distance as that will exclude certain protocols. I2C and SPI are, generally speaking, used over short distances, same PCB or a few tens of centimeters whereas using the UART / TCP/IP could be anything from a few centimeers to the other side of the planet.

Once you know the distance they need to communicate over the next thing is the data being transferred. Is it bidirectional with either instigating transmission or will one be a slave to the other? This again will possibly favour one protocol over another.

The WiKi should give a few examples of using each protocol and reading through may give you further thoughts on the best to use.

Regards

OderlandoRSilva
Posts: 36
Joined: Mon Oct 30, 2023 1:17 pm
Has thanked: 3 times
Been thanked: 5 times

Re: Data transmission between 2 STM32 microcontrollers

Post by OderlandoRSilva »

Hello. I really appreciate your participation in clarifying my question. The communication used between the two STM32 microcontrollers must be bidirectional.

OderlandoRSilva
Posts: 36
Joined: Mon Oct 30, 2023 1:17 pm
Has thanked: 3 times
Been thanked: 5 times

Re: Data transmission between 2 STM32 microcontrollers

Post by OderlandoRSilva »

I also have another question: I'm using a STM32F401RET6 and it has 6 UART channels. Is it possible to make more than 6 slave microcontrollers using just one master board?

chipfryer27
Valued Contributor
Posts: 1685
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: Data transmission between 2 STM32 microcontrollers

Post by chipfryer27 »

Hi

Again, depending on your protocol you can certainly use all six UARTS to communicate with six individual devices.

However depending on distance etc you may only need one channel; with all other devices on the same "connections", each with individual addresses.

Regards

OderlandoRSilva
Posts: 36
Joined: Mon Oct 30, 2023 1:17 pm
Has thanked: 3 times
Been thanked: 5 times

Re: Data transmission between 2 STM32 microcontrollers

Post by OderlandoRSilva »

So it is not possible to communicate with two peripherals on a single UART channel (Short distances)?

chipfryer27
Valued Contributor
Posts: 1685
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 374 times
Been thanked: 583 times

Re: Data transmission between 2 STM32 microcontrollers

Post by chipfryer27 »

Hi

It really depends on your protocol if it allows multiple devices over the same connections/channels. I2C allows as does SPI (albeit with individual select pins).

Regards

Post Reply