Skip to main content
Associate II
January 17, 2024
Solved

SPI COMMUNICATION THREE WIRE/ FOUR WIRE

  • January 17, 2024
  • 1 reply
  • 13013 views

Hi,

I have doubt with the spi communication setup in this configuration. I'm using two sensors where one of the sensor only support 3 wire spi and another  is 4 wire .I have a single spi in mcu. The hardware setup is followed by mapping four wire spi to mcu(mcu is configured in full duplex mode) and put a resistor between miso and mosi and given to three wire spi slave. 

>Is it possible to make proper communication in this setup?

>If this is okay how the master mcu will differentiate betweeen them?

    Best answer by TDK

    Technically, yes. You would need to reconfigure the peripheral in 3-wire mode when you wanted to use that mode and switch to 4-wire mode for the other sensors. Not something that will be supported by CubeMX.

    1 reply

    Ghofrane GSOURI
    ST Technical Moderator
    January 17, 2024

    Hello @Error_Code 

    First let me thank you for posting.

    1- Yes you can make a proper communication using this setup.
    Serial Peripheral Interface (SPI) allows full-duplex or half-duplex synchronous serial communication with multiple devices over 3 or 4 wires.
    For example  by checking the datasheet of the sensor ADXL345 ( Digital Accelerometer)

    GhofraneGSOURI_0-1705485628712.png

     


    2- To differentiate between the two sensors, you can use a separate GPIO pin as an additional chip select (CS) for the 3 wire sensor.

    Thx

    Ghofrane

     

    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.
    Associate II
    January 17, 2024

    Thanks for your response,

    Is it possible to use both three wire and 4 wire spi in same spi bus? if yes how it will work?

     

    TDK
    TDKBest answer
    January 17, 2024

    Technically, yes. You would need to reconfigure the peripheral in 3-wire mode when you wanted to use that mode and switch to 4-wire mode for the other sensors. Not something that will be supported by CubeMX.

    "If you feel a post has answered your question, please click ""Accept as Solution""."