How to connect multiple SPI Slave Device

Status
Not open for further replies.

Svenson

Member
Hi guys, i'm newbie, so i'm trying to learn.

I have Teensy 3.2 and I'd try to connect 8 of this chip stp16dps05 via SPI (need to manage a ledRing)
https://www.st.com/resource/en/datasheet/stp16dps05.pdf

My first idea is to use a MCP23017 connected via I2C to set the CS pin in each of stp16dps05.

So MPC and stp16dps05 will share MOSI, SCK out from teensy, and MPC will set the CS on the stp16dps05.

So the code flow will be:

1 - mcp.digitalWrite to Set the mcp23017 via I2C to enable a specific CS
2 - SPI.transfer(value);
3 - mcp.digitalWrite to Set the mcp23017 via I2C to disable a specific CS

Do you think that is the correct way or totally wrong? Can i have some synch problem?
I read something about DaisyChain, is this the case?

I'd like to implement the best practice :)
 
Off hand, it probably depends on how fast you need to switch from device to device. In terms of computer speeds, i2c is fairly slow. I don't know if using 16 i2c transactions (8 to set the CS bit on, 8 to set the CS bit off) would be enough to visibly slow whatever you are doing. For a normal display, it might not matter. If you are doing POV (persistence of vision), it may. You could be clever and bank all of the CS bits in 0-7 or 8-15, and then use one i2c transaction to change one CS pin high and the other low at the same time.

Here is a paper on improving SPI bus design, particular in SPI buses with multiple clients on the bus: https://www.pjrc.com/better-spi-bus-design-in-3-steps/.

I would imagine you do want to use SPI transactions so that it can properly wait for one transaction to finish before doing the next one.

I don't know if the pull-up resistors in the MCP2017 are strong enough to be used, whether the device has its own pull-up resistors, or whether you would need to add your own pull-up resistors.

Hopefully the chip properly does tri-stating for MISO.

For only 8 CS bits, I would be tempted just to use normal pins on the Teensy 3.2, unless you need all of the pins for something else. In case you didn't know it, pins A0 .. A9 can be used as digital pins. Pins A10-A14 cannot be used as a digital pin.
 
Status
Not open for further replies.
Back
Top