Pages: [1]   Go Down
Author Topic: Can I share the SCK pin (13)?  (Read 330 times)
0 Members and 1 Guest are viewing this topic.
Europe, Malta
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

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?
Logged

UK
Offline Offline
God Member
*****
Karma: 17
Posts: 568
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged

0
Offline Offline
Shannon Member
****
Karma: 159
Posts: 10409
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: