Multiple Shield Using the same pin

Hello. I am very new to Arduino. I come from a software background and would like to tinker around with Arduino which I found very interesting and have alot of ideas on how to use it.

RIght now I am trying to understand. How to integrate 2 different shields (W5100 and RFID MFRC522) with my Arduino UNO. I have read on the manual that W5100 uses pin 10,11,12,13 and on the MFRC
it uses * MOSI: Pin 11 / ICSP-4, * MISO: Pin 12 / ICSP-1,* SCK: Pin 13 / ISCP-3, * SS: Pin 7,

  • RST: Pin 9. (Taken from the Rfid master card read example)

Now from that configuration there's 3 overlapping pins that both shield uses. I ran a code that I got from one of the poster here on this forum. Everything seems to work other after disabling the SD PIn on the W5100 ethernet shield. My question here is does this overlapping of pins worked? When can I overlap the pins when 2 or more shield need to use the same pins? When can I overlap the pins and when can't I?

Thanks,
D

Yes, these pins are used for MOSI, MISO and SCK.
This is a bus system, they can be used to communicate to multiple devices at the same time*.

MOSI: Master Out Slave In.
MISO: Master In Slave Out.
SCK: Serial Clock.

The bus also needs another pin, SS or Slave Select.
This is the trick here.
When SS is active, MOSI and MISO are valid for the device that is addressed by that single pin, the other devices on the bus are supposed to ignore what's going on on that bus.
Your devices use pins 10 and 7 for SS, so all is good here, nothing to worry about.

Very good that you saw this, usually people ask after building their project why it doesn't work with conflicting pins.
In your case there are no conflicts.

Hi Mas3,

Thank you for the reply.

So MISO, MOSI, SCK pin can be overlapped. However SS and RST cannot be overlapped?

Here's another question. On the code for the Card Read Example it's labling * MOSI: Pin 11 / ICSP-4

  • MISO: Pin 12 / ICSP-1, * SCK: Pin 13 / ISCP-3 . Isn't the ISCP the middle 6 pin on the Arduino Uno?
    does this mean that I can use those pin as well?

Thanks,
D

You could, these are connected together.
If they actually are shields, meaning they can be stacked on your Uno, then this connector will most probably be covered by the 1st. shield.
Some shields also connect to this connector and offer this to another shield stacked, some do not.

RST, for reset could or could not be connected to the same pin,i'm not sure.
It depends on your needs and that of the shields.
So to be sure i would assign different Uno pins to each shield's RST pin.

You have to be careful to check when sharing the SPI bus (SCLK/MOSI/MISO)
that all the connected devices have distinct CS (chip select) lines and whether
they use the same clock speed, bit order and mode. If these differ you may have
to explicit switch the settings on the SPI hardware between uses. If devices run
at different voltages then things get more complicated.

Check in the datasheets for the relevant chips what SPI options / speeds they
support.

The "SS" pin on the Arduino is "Slave Select", not "Chip Select" and is used when
the Arduino is acting as an SPI Slave. However it can also be used as a chip
select when the Arduino is the master, as here - however it must always be selected
as an OUTPUT when using the SPI hardware as master, whether its used or not.