I want a RPi to act as a SPI master and be able to communicate with 24 SPI slaves. The SPI connection is full-duplex. The SPI slaves are about 50 cm away from the master (SPI runs on wires to an other PCB board not considered here). The 24 slaves will be Blue Pill STM32 boards, I have to use DMA on the SPI slave (CPU is very busy).
I have successfully communicated using SPI with 50 cm unshielded cables with a reasonable enough baud-rate for my application (9 MHz).
I'm pretty sure (though I have not tested) I will run into problems because of the multiple SPI slaves and long wires so I designed a schematic and I would like you to tell me what may work and what may not. There is also probably room for simplifications.
Design
- I plan to use 3 daisy-chained
74HC595
shift registers to generate 24 outputs that will determine to which SPI slave the RPi will be connected to. - I plan to use
CD54HC125
quad tri-state buffers to isolate the other SPI slaves when connected to one, these would be driven by the shift registers outputs.
Raspberry Pi
SER
,SRCLK
andRCLK
drive the shift registersSPI_CS
,SPI_MISO
,SPI_MOSI
andSPI_SCLK
drive the SPI communication (RPi is the master)
Shift registers
SER
,SRCLK
andRCLK
driven by the RPi- Daisy chained
- Each
SPI_x
output will drive a tri-state buffer
Tri-state SPI buffers
- There are 24 similar blocks like this, only the
SPI_x
changes - Each
01x04
male connector leads to one SPI slave - Output enable is driven by one of the shift register output (here
SPI_0
) SPI_MISO
is inverted because it is an output pin of the slave
This is my first KiCAD design, review and comments would be much appreciated before I buy components and try to test on a breadboard! After that I plan to layout the PCB and get it manufactured.
Edit ( July 2018): Real world test
I have just tested the communication between one Raspberry Pi (master) and 6 blue pill (STM32) boards, full-duplex.
Without any additional device and despite the poor wiring the communication works at 10 MHz reliably; 99.6% over 12 000 messages (checked with a Flechter sum)
Whether this scales up to 24 device or not remains a question :)