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