Go Down

Topic: Shift Register in SPI SCK Pin (D13 on UNO) (Read 6088 times) previous topic - next topic

ultimate1112

Hi,
Is it possible to have the shift register clock pin (sometimes known as SH_CP) on D13, while using another SPI device at the same time?
My project is to have data received from a transmitter (NRF905, using SPI) and display on the Arduino TFT LCD. I want to cut back on the pins on the receiver, and have seen that half of the pins can be run on a shift register.  I will be using the ordinary 74HC595.
Thanks in advance.

Peter_n

#1
Sep 24, 2014, 06:44 pm Last Edit: Sep 24, 2014, 06:49 pm by Peter_n Reason: 1
Yes, the SPI bus uses a Chip Select to select the device. So you need a Chip Select for each device. The other signals (data out, data in, clock) are shared.

Also in software, every devices is seperated from the other. For example when you use a function from the Ethernet or SD library, when that functions returns, the Chip Select for that device is inactive again.

That is how you should also use it: activate chip select, do SPI transfer, make chip select inactive.

Or do you want to toggle the clock yourself with digitalWrite while the SPI has been initialized for other SPI devices ? That is not good, use the SPI functions once the SPI has been initialized.

kowalski


Is it possible to have the shift register clock pin (sometimes known as SH_CP) on D13, while using another SPI device at the same time?

Yes, here is a Shift Register Parallel Output (SRPO) class and an example sketch.

https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/SPI/Driver/SRPO.hh
https://dl.dropboxusercontent.com/u/993383/Cosa/doc/html/de/d8f/classSRPO.html
https://github.com/mikaelpatel/Cosa/blob/master/examples/Sandbox/CosaSRPO/CosaSRPO.ino


Please see the circuit/wiring descriptions in the above files.

Cheers!

Go Up