meminoglu
Posts: 23
Joined: Sun Mar 05, 2017 3:15 pm

Is raspberry pi 3 supports more than 5 SPI slaves?

Fri Nov 09, 2018 3:55 pm

Hi, i run 5 rc-522 module on raspberry pi. I use both spi (spi0 and spi1) There are 2 CS pin on SPI0 and there are 3 CS pin on spi1. And i use successfully 5 RC-522 module.

But I want more! i need it. I found 74hc4067 module, but i didn't try it. and i found another module mcp23s17... i want to ask, are these modules fit for me? and do you have any other suggestion?

[My Point is, i want to control more than 5 RC-522 module]
Last edited by meminoglu on Fri Nov 09, 2018 5:01 pm, edited 1 time in total.

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Fri Nov 09, 2018 4:02 pm

Pick a GPIO to use for CS

Add

Code: Select all

 dtoverlay=spi2-1cs,cs0_pin=??
with the GPIO number you've chosen that adds /dev/spidev2.0

Pick two GPIOs, Use

Code: Select all

dtoverlay=spi2-2cs,cs0_pin=??,cs1_pin=??
with the two separate GPIOs you've chosen that will add /dev/spidev2.0 and /dev/spidev2.1

There's also a spi2-cs3 overlay. Docs are in /boot/overlays/README
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

DirkS
Posts: 9217
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 12:37 pm

DougieLawson wrote:
Fri Nov 09, 2018 4:02 pm
Pick a GPIO to use for CS

Add

Code: Select all

 dtoverlay=spi2-1cs,cs0_pin=??
with the GPIO number you've chosen that adds /dev/spidev2.0
I thought that spi2 is only available on the Compute Module...

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 1:21 pm

DirkS wrote:
Sat Nov 10, 2018 12:37 pm
DougieLawson wrote:
Fri Nov 09, 2018 4:02 pm
Pick a GPIO to use for CS

Add

Code: Select all

 dtoverlay=spi2-1cs,cs0_pin=??
with the GPIO number you've chosen that adds /dev/spidev2.0
I thought that spi2 is only available on the Compute Module...
I don't know, I've not tried it and I'd not, yet, read the DTS source for that overlay.
The docs say it's CM only but that's only true if using the default pins in the overlay.
https://github.com/raspberrypi/linux/bl ... verlay.dts
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

DirkS
Posts: 9217
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 1:32 pm

DougieLawson wrote:
Sat Nov 10, 2018 1:21 pm
I don't know, I've not tried it and I'd not, yet, read the DTS source for that overlay.
The docs say it's CM only but that's only true if using the default pins in the overlay.
https://github.com/raspberrypi/linux/bl ... verlay.dts
Problem is that GPIO40 to 42 (the SPI2 MISO, MOSI and CLK) are not broken out on the GPIO header.
You can change CS, but not the other 3

User avatar
DougieLawson
Posts: 34096
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 1:34 pm

DirkS wrote:
Sat Nov 10, 2018 1:32 pm
DougieLawson wrote:
Sat Nov 10, 2018 1:21 pm
I don't know, I've not tried it and I'd not, yet, read the DTS source for that overlay.
The docs say it's CM only but that's only true if using the default pins in the overlay.
https://github.com/raspberrypi/linux/bl ... verlay.dts
Problem is that GPIO40 to 42 (the SPI2 MISO, MOSI and CLK) are not broken out on the GPIO header.
You can change CS, but not the other 3
In that case we'd need to pick a full set of five pins (MISO, MOSI, CLK, CE0 & CE1) and write our own overlay for it.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

2012-18: 1B*5, 2B*2, B+, A+, Z, ZW, 3Bs*3, 3B+

Any DMs sent on Twitter will be answered next month.

danjperron
Posts: 3072
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Is raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 1:46 pm

You could use GPIO with an 74HC138 to make 8 chip select.

3 GPIOs to select which output and one of the real CS (chip select) .
Using the same GPIO for ABC input on three 74HC138 which each of them using a different CS you could upgrade the resulting CS up to 24.

The only thing is that you will have to create a function to select the correct GPIO first. if the code is on the same application it is not a problem. If it is multiple applications then you need to create a semaphore mechanism (lock/unlock).

Daniel

danjperron
Posts: 3072
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Is raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 1:56 pm

Also if you want to control more than RC522 module you should check my modbus RC522 modules.

Now the limit is the number of module on the RS-485 bus which will depends on then 485 I.C. and it could go up to 1200 meters. Rougtly 64 units.



https://github.com/danjperron/modbusMFRC522

meminoglu
Posts: 23
Joined: Sun Mar 05, 2017 3:15 pm

Re: İs raspberry pi 3 supports more than 5 SPI slaves?

Sat Nov 10, 2018 10:24 pm

DougieLawson wrote:
Sat Nov 10, 2018 1:21 pm
DirkS wrote:
Sat Nov 10, 2018 12:37 pm
DougieLawson wrote:
Fri Nov 09, 2018 4:02 pm
Pick a GPIO to use for CS

Add

Code: Select all

 dtoverlay=spi2-1cs,cs0_pin=??
with the GPIO number you've chosen that adds /dev/spidev2.0
I thought that spi2 is only available on the Compute Module...
I don't know, I've not tried it and I'd not, yet, read the DTS source for that overlay.
The docs say it's CM only but that's only true if using the default pins in the overlay.
https://github.com/raspberrypi/linux/bl ... verlay.dts
I tried your suggestion, but now i lost raspberry ethernet, i cant access over ssh. When i tried different sd card, ethernet works. I cant get view right now, i will try to look boot process, i can only connect via ssh right now. (i tried change config.txt file, but still same)

Return to “Advanced users”