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 ?

1 ACCEPTED SOLUTION

Accepted Solutions

@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?)

View solution in original post

12 REPLIES 12
SofLit
ST Employee

Hello, 

Not clear: you need a communication with UART or SPI?

Related threads:

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

 

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.

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

So why the title mentions UART?

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.

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
Up vote any posts that you find helpful, it shows what's working..

@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?

okay, i think there is a misunderstanding of how things are explained here. yes, i have done communication with uart between both devices and it is working fine. i have a genuine doubt that with the connector can i communicate through spi, i2c same like uart?


@suhfi wrote:

okay, i think there is a misunderstanding of how things are explained here. 


Indeed - your posts are not very clear at all!

 


@suhfi wrote:

 i have a genuine doubt that with the connector ...


What "connector" are you talking about?

This one:

AndrewNeil_0-1731320656424.png

Check out the Raspberry Pi documentation to see what signals are available on that connector:

AndrewNeil_1-1731320882158.png

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-and-the-40-pin-header

You can clearly see that UART (TXD, RXD), SPI (MOSI, MISO, SCLK), and I2C (SDA, SCL) are all available on that connector, and documented on that page:

https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#alternative-functions 

and 3rd-party sites; eg,

https://learn.sparkfun.com/tutorials/raspberry-pi-spi-and-i2c-tutorial/all

https://blog.adafruit.com/2022/02/04/the-raspberry-pi-4-has-more-spii2c-uart-ports-piday-raspberrypi-raspberry_pi/

 


@Andrew Neil wrote:


your posts are not very clear at all!


@suhfi  One thing that would help would be to provide diagrams/pictures - so that we can actually see what you're taking about, rather than just rely on text.

Especially as there seems to be a bit of a language barrier.

okay, thank you for the advice. i am gonna follow that. no i am not talking about the connector over there. i am talking about the usb connector. 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?