cancel
Showing results for 
Search instead for 
Did you mean: 

STM32 to StM32 with SPI

Greybeard
Associate II

I know there are hundreds of posts about this and I've been through most of them but still can't get things to work.

The concept is simple: set up 2 Nucleo F446 boards, one as full duplex slave the other as full duplex slave.

Master pseudo code:

while 1

   Zero buffers

   Fill Transmit buffer with data

  Pull CS pin low

use Hal_TransmitReceive(..)

Wait for a while

 

 

The Slave pseudo code is similar

 While 1

    Zero buffers

    Fill tansmit buffer

   Wait for CS to go low

  use HAL TansmitReceive(..) to get data

 Shorter Wait than Master

 

I am using a logic analyzer to monitor the data plus selected breaks in the debugger to see what is received.

The last test was with a clock frequency of 740 KHz. 

Summary: 

The MOSI line always has the right data according to the logic analyzer but slave never receives data. Master never receives valid data(verified using break point)

 

The MISO line has random data according

Slave never receives data transmitted data just random characters. (verified using breakpoints) 

Reversing functionality of the two F446 yields same result.

Using a simple loop back on (MOSI & MISO) shows that each Nucleo can receive the data.

I have tried several Nucleo boards over the past week with the same result.  I have use G431RE, G431K, F446RE, and F042K.  All produced the same results. 

I have probably missed something simple. 

HELPPPP!!!!!  before I pull the last hair out of my head.

5 REPLIES 5
Greybeard
Associate II

Sorry, Its Master to Slave and Yes; Master raises the CS line after TransmitReceive

Common ground between the boards?

MNapi
Senior III

it is usually the timing you read before the other board transmitted

see examples in CubeMX

The boards have a common ground wire.

...and that's the comma that changes everything.....