Skip to main content
Associate III
November 9, 2024
Solved

Communication between stm32 and raspberry pi4 through spi or i2c.

  • November 9, 2024
  • 3 replies
  • 11309 views

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 ?

Best answer by Andrew Neil

@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 @mƎALLEm 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?)

3 replies

mƎALLEm
ST Technical Moderator
November 9, 2024
To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
suhfiAuthor
Associate III
November 9, 2024

earlier i have done communication with uart, can i use the same connector or connections for spi also? if not how should i connect?

mƎALLEm
ST Technical Moderator
November 9, 2024

So why the title mentions UART?

To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
Tesla DeLorean
Guru
November 9, 2024

Why SPI?

Why can't you figure out what the issues are with USB/UART and fix/address those?

You have RPi side drivers that can do SPI simply?

Is the power supply or setup adequate to support the NUCLEO and everything else hung off it?

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
Andrew Neil
Super User
November 9, 2024

@suhfi wrote:

as in my previous query


These:

https://community.st.com/t5/stm32-mcus-embedded-software/uart-communication-between-raspberry-pi-4-and-stm32f411re/td-p/736436

https://community.st.com/t5/stm32-mcus-products/communication-between-nucleo-f411re-and-raspberry-pi-using-st/td-p/721443

 


@suhfi wrote:

I have downloaded the zip file ?


What zip file?

 


@suhfi wrote:

 from the web builder GRBLHAL.


The what??

 


@suhfi wrote:

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.


What do you mean by that?

Sure, you can always use a connector to make connections - it's in the very name!

 


@suhfi wrote:

how can be the easy way to communicate between raspberry pi 4b and stm32f411re.


You've already seen that you can do this with a UART link - either direct or via USB.

So what do you think is not "easy" about this?

What problem(s)/limitation(s) do you have that you think that SPI (or anything else) might solve?

I see no reason to believe that SPI is going to be any easier than UART. On the contrary, UART is very widely used and easy to test - so, if you're stuck with that, I can't see that you'll fare any better with anything else.

 


@suhfi wrote:

in that file i am not able to find uart communication


What file?

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.