cancel
Showing results for 
Search instead for 
Did you mean: 

Communication between stm32 and raspberry pi4 through spi or i2c.

suhfi
Senior

Hello, I am doing a project with STM32F411RE NUCLEO board. I have downloaded the zip file from the web builder GRBLHAL. i have attached the file here. And I have successfully imported the zip folder onto the stm32cubeide. So for that project I want to add communication through SPI. and there is a SPI communication can be used for that project.

as in my previous query, i came to know that with UART communication, USB connector which is connected to cn1 of the board and raspberry pi USB connection - i am able to communicate. as i understood that, to communicate between raspberry pi  and stm32, i don't need to connect tx of pi -> rx of board, rx of pi -> tx of board, gnd to gnd. but can able to communicate through a connector. will that be possible with spi communication also. if no, then how can be the easy way to communicate between raspberry pi 4b and stm32f411re. and i forgot to mention that, in that file i am not able to find uart communication, i can only see the header files of spi, i2c, usb_device. can you please give me clarity over this ?

12 REPLIES 12

@suhfi wrote:

 as in my previous discussion i came to know that usart via usb is possible between raspberry pi and stm32 nucleo board. i am wondering if usb connector supports i2c or spi just like uart?


No. Only UART is supported over STLINK via Virtual COMPORT. Neither SPI, nor SPI is available over STLINK.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.

@suhfi wrote:

i am talking about the usb connector?


So why didn't you say that? You can see that there are (at least) 10 different connectors on the Raspberry Pi - how did you expect us to guess which one you meant?!

 


@suhfi wrote:

i am wondering if usb connector supports i2c or spi just like uart?


There are USB-to-I2C and USB-to-SPI converters available; eg,

I2C: 

https://ftdichip.com/products/umft201xb-01/

https://ftdichip.com/products/umft200xd-01/

SPI/I2C:

https://ftdichip.com/products/ft2232h-56-mini-module/

https://ftdichip.com/products/ft4232h-56-mini-module/

 

But, as @SofLit said, the Nucleo board routes neither I2C nor SPI via its ST-Link.

 

A standalone ST-Link V3 can route UART, SPI, and I2C

https://www.st.com/en/development-tools/stlink-v3set.html 

(not sure if that's all 3 at once, or just one at a time?)


@suhfi wrote:

 i am wondering if usb connector supports i2c or spi just like uart?


You still don't really seem to have understood what's happening in the UART case.

It's not the "USB connector" which supports UART - it's the USB-to-UART converter which does that.

In the case of the Nucleo board, that USB-to-UART converter is part of the ST-Link.

 

Thus, to get the same support for I2C or SPI or anything else, you need a USB-to-whatever converter.

 

USB-to-UART converters are very common and widely supported - other things, not so much.