Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to detect SPI slaves?

Status
Not open for further replies.

michcfr

Advanced Member level 4
Joined
Mar 7, 2012
Messages
106
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
2,011
Hello,

I want to connect peripherals to a MCU with SPI in Master-Slave mode. The MCU is the master, peripherals are slaves.
Slaves are connected in parallel: I use 3-8 decoder from the MCU to select the potential 8 SPI peripherals (through their SS pin).

Do you know how the MCU can detect if SPI slaves are attached to the SPI-bus?


Regards,
Michel
 

It can't unless the slave returns something meaningful. You would have to select each possible slave in turn, clock some data from it and see if it was recognized. In most cases there will be a status register or similar you can read back.
Alternatively, if the slave passes bits straight through it, you could send a bit of data and clock it right through the slaves shift register and see if it came out at the other end.

Brian.
 

It can't unless the slave returns something meaningful. You would have to select each possible slave in turn, clock some data from it and see if it was recognized. In most cases there will be a status register or similar you can read back.
Alternatively, if the slave passes bits straight through it, you could send a bit of data and clock it right through the slaves shift register and see if it came out at the other end.

Brian.

ok. I can do it this way. Thank you for your response.

Alternatively, do you think we can use pull up resistor at the device end like USB to detect the presence of a device connected to its port? see section "speed identification" in: https://www.beyondlogic.org/usbnutshell/usb2.shtml


Regards
Michel
 

I don't see a relation to USB. But a MISO pull-up (or pull-down) would allow to detect more easily, if the SPI slave is activating it's output driver when selected.
 

...but be careful because if all the devices are in parallel except their select pins, it's possible to read back a response from the wrong device.

Brian.
 

...but be careful because if all the devices are in parallel except their select pins, it's possible to read back a response from the wrong device.

Brian.
That would only happen if a slave device is a rouge device that responds when not selcected or if the master selects the wrong device.
 

...but be careful because if all the devices are in parallel except their select pins, it's possible to read back a response from the wrong device.

Brian.

so, you mean if MCU select one device that is not connected, it may get response from the wrong device? how to resolve this issue?

michel

- - - Updated - - -

I don't see a relation to USB. But a MISO pull-up (or pull-down) would allow to detect more easily, if the SPI slave is activating it's output driver when selected.

Yes, I saw many devices where all of the signal lines (MISO,MOSI,CLK,CS) have 10k pull up resistors.
What do you mlean "detect more easily"?

Michel
 

Yes, I saw many devices where all of the signal lines (MISO,MOSI,CLK,CS) have 10k pull up resistors.
What do you mlean "detect more easily"?
I think he means if the slave activates its output driver as soon as it is selected, and if that output driver is in the opposite direction from the pull-up or pull-down, then you can tell if it connected without bothering to send real data. Just activate the select line and check the MISO line as a digital input. But this will only work if all the slaves are designed to activate the MISO line in the opposite direction from the pull-down or pull-up resistors as soon as they are selected.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top