cancel
Showing results for 
Search instead for 
Did you mean: 

What's the best protocol (USART mode?) for high-speed bidirectional comm between two STM32s?

TB
Associate III

I’m designing a motor control PCB with two STM32G432RBs (situated close to each other on the PCB) driving a boatload of H-Bridges, encoders, servos, and other I/O. I’m planning a dedicated (synchronous) USART connection between the two STM32G4s to keep them coordinated. Speed and bidirectional comm matter in this setting (power not as much). What is the maximum data rate (Mbps) that I can reasonably expect in this set up (I can only find one mention of a "max USART clock freq", of 21 MHz, in the datasheet),

[Or should I use SPI instead? I am confused by the phrase "SPI-like" in the sentence from the datasheet "The USART1, USART2 and USART3 also provide a Smartcard mode (ISO 7816 compliant) and an SPI-like communication capability."....]

Finally: USART can run in many different "modes"; what is the best ("native"?) USART comm mode to use in such a setting?

12 REPLIES 12

> connect both USART and SPI (that will be 4 wires by shorting pins together MOSI+TX, MISO+RX)

Or maybe connect them separately, using one for short fast packets, and the other for bulk data.

> USART is simpler to use and you need a SW mecanism to wrap and sync data payloads.

There is the break signal or the receive timeout feature for framing packets.

MikeDB
Lead

I'd connect an SPI port on each MCU together and use that - it will always be faster than a USART and you can define your own protocol.

if you can find a gpio which can be either SPI or USART (eg MOSI/TX...) this keeps your SW options open for change later on.

Due to lack of SmartIO, the pinout shall be carefully defined manually over the datasheet pinout table.

Happy hunting.

PS: SPI evolved for serial memories in QSPI and OSPI interfaces for even higher speed,

Keep in mind that the max SCK frequency is 1/4 th of SYSCLK for slave and 1/2 SYSCLK for the master.