Computing > Embedded Computing

Serial communication between Raspberry Pi 4 and STM32F4

(1/1)

johofz:
Hello dear EEVblog community,

I'm working on a project that requires communication between a Raspberry Pi 4 (master) and an STM32F4 (slave).

The Pi is supposed to send commands to the STM32F4 to start a measurement and then receive a stream of data until the measurement is done.
My first intent was to use USB, since the STM32F4 I'm using has a USB-OTG FS layer on it's silicon and I previously used that to communicate with PCs.

The STM32F4 together with analog, power and motor controller circuits is on a single PCB. This PCB will most likely be larger than the Pi's board. I plan on mounting the Pi onto my measurement board and connect them via the pis header.

As far as I know, the Pi does not provide USB D+/D- over the header. This is a bummer, since it would require a cable and I don't want that.

Does anyone have experience with URAT or SPI communication between the two? I did a lot of SPI communication but never used a Pi for that befor.

Greetings
johofz

technix:
The serial UART pins on the header is not useable by default because of the lack of a stable clock going to the second UART causing the baudrate to change in the middle of a communication. If you can get away without Bluetooth, you can redirect the primary UART interface to the GPIO pins so you get a direct serial link. Alternatively, you can use some SPI/I2C to UART chip like SC16IS740 to create a stable-clocked serial UART interface from I2C or SPI bus. Or what might be the easiest, have the STM32 and the Pi talk directly over SPI or I2C. STM32 would be the slave device and Pi being the master.

Anyway, it doesn't make much sense to use USB as the link between Pi and some slow peripheral.

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version