cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting two stm32 boards via SPI

devie andriyani
Associate II
Posted on April 12, 2018 at 05:50

Hi everyone, i'm trying to use two stm32 boards (STM32F411DISC &STM32F407VGT) for SPI communication. How to interface the SPI with Two stm32 boards, one act as master another one act as Slave and declare their pins on the cubemx?

12 REPLIES 12
Tilen MAJERLE
ST Employee
Posted on April 12, 2018 at 06:46

Hello,

in the STM32CubeF4 package, you have an example with SPI_2boards. You may use it as a reference.

Best regards,

Tilen

Posted on April 12, 2018 at 06:56

thx for your responding, Tilen. I have used SPI1 on two stm32 boards. One act full duplex master another act full slave. I've generated their code using MDK5. But I still confused how to display their SPI results?

Nesrine M_O
Lead II
Posted on April 12, 2018 at 10:43

Hi

devieandriyani9

,

As it is suggested by Tilen, ready examples thatshow how to ensure SPI data buffer transmission/reception between

two boards ,are included in our STM32cubeF4 firmware package:

STM32Cube_FW_F4_V1.0\Projects\STM32F411E-Discovery\Examples\SPI

I recommend you to start with these examples to develop you own application

You canget the

STM32CubeF4 package via this

http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm32-embedded-software/stm32cube-mcu-packages/stm32cubef4.html

-Nesrine-

Posted on April 12, 2018 at 10:28

nothing is easy,

everyone here has to work though so many issues,  don't be discouraged.

nice to see you join the club,

to view SPI data:

can you get an LCD project running ?

or you will have to use a serial port.

try an example LCD project and set up a text window.

send your SPI data to the LCD text window or to the serial port.

You can view the serial data on a terminal emulator.

or I guess you could use a break point in your code, if your IDE supports it.

Posted on April 12, 2018 at 10:42

I don't use an LCD project, only use terminal emulator to view SPI data. Many thanks

Majerle.Tilen

for your answers and suggestions

Posted on April 12, 2018 at 10:46

How do you use a terminal emulator to view SPI data??

Terminal emulators (generally) work with async - 'U(S)ART' - comms; not SPI!

Posted on April 12, 2018 at 10:50

thx a lot for your recommendation,

ELMHIRI.Syrine

. I'll try that later.

Posted on April 12, 2018 at 10:57

T J wrote:

nothing is easy,

everyone here has to work though so many issues

Indeed.

A very common beginner's mistake is to jump in too deep, and try to do too much all at once.

A classic example is trying to write both an SPI slave and an SPI master all at once and then expect it all to  'just work'.

But then, When it doesn't work, how can you tell if the problem is with the master, or the slave - or both?!

The way to approach a project is always to break it down into small steps; eg, first get your Master working with a known-good slave. Then, once you know the Master is good, move on to making the Slave.

It is also important to think about how you will debug a project from the start.

Hence I suggest the following for getting started - on any microcontroller:

https://www.avrfreaks.net/comment/1138166&sharpcomment-1138166

 

This is the approach that I would take myself when starting any new project.

Posted on April 12, 2018 at 11:00

I use Analyzer2Go software as terminal emulator. So, I have two stm32 boards. Early, I use them as master and slave. But i don't have saleae logic analyzer