Skip to main content
Explorer
October 29, 2024
Question

How to perform SPI communication within a board (master and slave)

  • October 29, 2024
  • 2 replies
  • 1332 views

How to perform SPI communication within a board (master and slave)

We are trying to loop back SPI communication within the board, and perform transmission by the slave and reception by the master on one board.

The master's SPI CLK is connected to the slave's CLK,
but when the master is receiving, does the master not generate a CLK?
(In other words, the slave never transmits.)
Does the slave's CLK need a separate CLK input?

 

Sorry for our poor English.

    This topic has been closed for replies.

    2 replies

    Super User
    October 29, 2024

    This is basic SPI operation.

    https://en.wikipedia.org/wiki/Serial_Peripheral_Interface

    https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all

    It is always and only the Master which generates clocks

     


    @pass3master wrote:

    We are trying to loop back SPI communication within the board, .


    Not sure what you mean by that?

    SPI is inherently a full-duplex link; ie transmission & reception happen simultaneously - that's why there are separate MOSI and MISO lines ...

    Explorer
    October 29, 2024

    "SPI is inherently a full-duplex link; ie transmission & reception happen simultaneously - that's why there are separate MOSI and MISO lines ..."
    understand the above content. However, I have no choice but to create it at the request of our customers.
    Is it possible to have the master receive and the slave transmit at the same time?
    If I do that, the master will generate a CLK when it receives, and the slave will receive a CLK when it transmits.
    Can I solve this by using DMA or something?

    Super User
    October 29, 2024

    @pass3master wrote:

    Is it possible to have the master receive and the slave transmit at the same time?


    Of course - that is what full-duplex means!

    While data is being clocked Out of the master on MOSI, it is simultaneously being clocked In to the Master on MISO

    ST Employee
    October 29, 2024

    Hello @pass3master  , 

    I recommend checking out this article Getting started with SPI - stm32mcu , It explains SPI and provides examples for using it with STM32 microcontrollers. This should be very helpful for your project.

    Best regards,