Electronic – Is it possible for a SPI slave to talk to other slaves

picspi

I'm developing a device that will have a flash chip and a RTC on the same SPI bus, selected using two different select lines. I also have a front panel for this device that needs to access these devices and is currently wired up to a UART, but I'm thinking of making it also an SPI device so I wouldn't have to use the extra pins.

My basic question is this – could I somehow have the front panel MCU, which will be an SPI slave, talk to the other slave devices on the bus somehow? If not, how would I be able to achieve this? I'm thinking about doing this by re-initializing the SPI bus by causing an interrupt on my main MCU, but I'd rather first see if anyone here knows if I can do slave to slave SPI comms.

Thanks for any help.

Best Answer

A "slave" SPI device that controls another slave becomes a master by definition.

If your front panel software is capable of implementing either slave or master roles at different times there is nothing to stop it doing so, provided that the hardware can accomodate the necessary signal flow and the "normal" SPI master does not interfere or "become confused" by the action. ie

  • Your masters need to cooperate physically: If two masters try to work at once, or if one master asserts a signal line (eg clock) that affects the ability of the other master to control the same line when desired then "there will be problems".

  • Your masters need to cooperate logically: If one master "thinks" it is controlling the bus but the other is also altering the clock or data lines "there will be problems".

From the UART and SPI IC's point of view the physical identity of the master device is unimportant as long as the signal levels and signal flow occurs correctly.