cancel
Showing results for 
Search instead for 
Did you mean: 

SPI COMMUNICATION THREE WIRE/ FOUR WIRE

Error_Code
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions

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".

View solution in original post

5 REPLIES 5
Ghofrane GSOURI
ST Employee

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

 

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?

 

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".

If suppose this reconfiguration part is implemented , what about the hardware setup?. will it support?

Error_Code_0-1705554640296.png

The hardware setup will be like as shown above. My question is will that 10k resistor between MISO and MOSI can impact the communication between slave 1 and master mcu ?If no how the communication take place?

In 3 wire mode, the MOSI pin is used for both outgoing and incoming data. No need to connect them.

However, no, the 10K shouldn't affect anything, but it's also not necessary.

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