Go Down

Topic: Can I share the SCK pin (13)? (Read 822 times) previous topic - next topic



I am using an SD card reader that requires SCK (pin 13) and now I need to add an nrf24l01 http://playground.arduino.cc/InterfacingWithHardware/Nrf24L01 wireless module that also requires the use of SCK.

What are my options? Is it possible to modify the library to use another pin instead of pin 13? (I'm a bit worried as the pins are not listed under "configurable"). Or could I wire up both the SD card reader and the wireless module to the same pin?


They should both be SPI devices and actually sharing SCK, MOSI and MISO. Each should be on a separate Slave Select pin. This is usually labelled CSN on the nRF (Chip Select Not, as it's Active Low). The nRF also needs another pin for CE. This controls whether teh nRF is in Transmit or Receive mode.

The libraries being used should take care of asserting/de-asserting the respective SS pins, but it's not guaranteed. If in doubt then manually set their SS pins before and after using each device, to be safe. Only one device should be active at a time and then that will be the one to respond to any SPI data sent by the Master (the Arduino).


Libraries using SPI in interrupt routines will cause issues - you'll have to disable interrupts around
anything else using SPI in that circumstance.  If different devices want SPI setup differently
(clock speed, phase or mode) then you'll have to ensure the hardware is set before every use in
case a different library used the SPI bus last.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up