Page 1 of 1

More than 2 SPI slaves

Posted: Mon Mar 14, 2016 7:41 pm
by pmueller
Hello,

I like to connect more than two SPI slaves to the Raspberry.
Unfortunately there are only to chip select pins possible (/CS0, /CS1). I can use GPIO pins for all of the SPI slaves, but then I can't use /CS0 and /CS1 anymore.

I looked into the kernel sources and saw that there seems to be the possibility to define not using any chip select. But control the the chip select via port pins in the application. But this seems not to work (at least what I tried).

Has anyone more than 3 SPI devices running that way?

Thanks,
Peter

Re: More than 2 SPI slaves

Posted: Tue Mar 15, 2016 4:51 am
by TheRayTracer
You may successfully use more that two SPI style devices. You may simply use any free GPIO pin on the RPi to manually toggle the CS for the slave device. This may not work for all SPI devices, such as those that require the CS to go inactive between each byte of a transmission, but most devices would have no issue with using this method.

Re: More than 2 SPI slaves

Posted: Tue Mar 15, 2016 5:55 am
by brekee12
There is an additional auxilary SPI on B+ Zero 2B which is located on the header and have three CS. This is additional to the standard SPI, but separate handling by sofware. Study joan's pigpio library which makes the handling. Very usefull option!

Re: More than 2 SPI slaves

Posted: Tue Mar 15, 2016 9:45 am
by adun
The current spi-bcm2835 driver supports additional GPIO chip-selects. For driver performance the hardware chip-select pins (CE0,CE1) will be automatically converted to GPIO CS's pins.

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 1:07 pm
by thomen
Just wondering if anyone has done anything with more than 2 slaves using daisy chaining or the like?
I'm looking to wire up around 6 colour oleds using SPI

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 1:16 pm
by brekee12
As I mentioned auxilary SPI available on B+, 2B, Zero has three CE.

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 5:43 pm
by blushi
thomen wrote:Just wondering if anyone has done anything with more than 2 slaves using daisy chaining or the like?
I'm looking to wire up around 6 colour oleds using SPI
I did actually. See my post: viewtopic.php?p=940975#p940975 (even though I am facing now some issues, you can get the idea ;) ) If you have any further questions, I'd be glad to help.

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 7:18 pm
by mikronauts
http://www.mikronauts.com/raspberry-pi/ ... and-howto/

Shows you how to generate eight chip selects from one...

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 9:21 pm
by thomen
I was hoping to Daisy chain 6 oled small screens. Do you think that would be possible??

Re: More than 2 SPI slaves

Posted: Tue Mar 29, 2016 9:36 pm
by thomen
Wow micronaughts I can't even begin to understand half of what you've written! (Being totally green and all) time to Google like crazy and read electronics for dummies ha-ha..

Re: More than 2 SPI slaves

Posted: Thu Mar 31, 2016 6:40 pm
by mikronauts
Hi.

You can't daisy chain SPI, as each device needs its own chip select.

You can daisy chain i2c.

The circuit in my article basically adds a "one of eight" de-multiplexer, and uses that to generate individual chip selects from a three bit binary number, and one of the chip selects on the GPIO connector.

Re: More than 2 SPI slaves

Posted: Thu Mar 31, 2016 9:31 pm
by thomen
Thanks !
I'll give it a try! I wanted to try and run up to 6 oleds with a pi

Re: More than 2 SPI slaves

Posted: Sun Apr 24, 2016 7:37 am
by crishoj
Are you certain that daisy-chaining on SPI is not possible?

Daisy-chaining with a single, shared chip-select seems to be a common mode of operation. See e.g. http://www.petervis.com/Raspberry_PI/SP ... Chain.html

Re: More than 2 SPI slaves

Posted: Sun Apr 24, 2016 10:01 am
by joan
crishoj wrote:Are you certain that daisy-chaining on SPI is not possible?

Daisy-chaining with a single, shared chip-select seems to be a common mode of operation. See e.g. http://www.petervis.com/Raspberry_PI/SP ... Chain.html
That does not make sense. I suggest you contact the author and ask for clarification. He may have a very specialised use with one model of chip in mind.

Re: More than 2 SPI slaves

Posted: Sun Apr 24, 2016 10:58 am
by crishoj
Of course, the SPI devices in a chain would have to support daisy-chaining, namely by re-transmitting their input to the next device on the following clock cycle.

See here for a description:
https://en.wikipedia.org/wiki/Serial_Pe ... figuration

Typical wiring, with one chip-select per device:
Image

Daisy-chain wiring, with a single, shared chip-select:
Image

Re: More than 2 SPI slaves

Posted: Sun Apr 24, 2016 11:09 am
by crishoj
Here is a specific example of chaining 3 AutoDrivers:
http://www.deathbylogic.com/2015/01/dai ... todrivers/

Data is shifted down the chain:
The way daisy chaining works with multiple devices on a single SPI bus is similar to shift registers, data from the SPI master is shifted out MSB first and shifted into the SPI slave on the falling edge of the SPI clock. At the same time the data in the slave is shifted out to the next device, when there is only a single slave device this would go back to the MISO pin on the master or with multiple slave devices the MOSI pin on the next slave. The number of devices that can be daisy chained together is only limited by length of the SPI bus and delay caused by each of the SPI devices on the SPI bus
Illustration:
Image

And here is a more technical description of the daisy-chaining SPI:
https://www.maximintegrated.com/en/app- ... vp/id/3947

I will be attempting a chained setup with 6 AutoDrivers in the coming weeks, and will be happy to report back how it goes.

Re: More than 2 SPI slaves

Posted: Sun Apr 24, 2016 12:08 pm
by joan
It's simpler just to use shift registers to implement shift registers.

I don't remember any posts where SPI daisy chaining has actually being used on the Pi.

Re: More than 2 SPI slaves

Posted: Thu Sep 07, 2017 4:13 pm
by peter.shea
chrishoj:
I will be attempting a chained setup with 6 AutoDrivers in the coming weeks, and will be happy to report back how it goes.
Did you ever get this working?

Re: More than 2 SPI slaves

Posted: Sat Sep 09, 2017 8:49 pm
by OutoftheBOTS
There is a second SPI bus that has another 3 CS pins see http://terminal28.blogspot.com.au/2016/ ... ero23.html
but also I found that to make room on the broad com chip you need to remove the Bluetooth or the serial console. I removed the serial console to use the SPI bus 1

Re: More than 2 SPI slaves

Posted: Wed Nov 15, 2017 1:12 am
by SteveA
Peter, from your original post, would you mind letting me know how you can disable the kernel from toggling CE0 or CE1 when using SPI because if that is what I have been trying to find out,
Thanks in advance
Steve