Skip to main content
Visitor II
April 16, 2024
Question

STM32 to StM32 with SPI

  • April 16, 2024
  • 3 replies
  • 2675 views

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.

    This topic has been closed for replies.

    3 replies

    GreybeardAuthor
    Visitor II
    April 16, 2024

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

    Graduate II
    April 16, 2024

    Common ground between the boards?

    GreybeardAuthor
    Visitor II
    April 17, 2024

    The boards have a common ground wire.

    Graduate II
    April 17, 2024

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

    see examples in CubeMX

    GreybeardAuthor
    Visitor II
    April 17, 2024

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

    Explorer
    September 9, 2024

    @Greybeard I am having a similer  problem my master transmits the data but slave does not recevie it and I can't found the problem. Here is my codes