SPI and two libraries


I tried to attach a nrf24 and a shift register 595 to an arduino pro mini. Both the nrf24 and the 595 use SPI for communication as far as I understood.
I used the RadioHead lib which works great RadioHead: nrf24_client.pde

and used the ShiftOut sketch https://www.arduino.cc/en/Tutorial/ShftOut23

Both combined works only if I use different pins. So eg hardware SPI for the nrf24 and 3 separate pins for soft spi for the 595.
Can't Use fot both the hardware SPI and safe pins?

You should be able to use the DATA and CLK SPI pins in common. The only pin that needs to be different is the CS pin as this is the pin that selects the device you are communicating with. The other device should ignore the SPI comms when it is not selected.

The 595 can be used with SPI but it is not an SPI device. You would have to wire it differently. Under normal SPI operation you would use a separate Slave Select pin for each SPI device to enable/disable reception. If using 595 along with other SOI devices you can still do this, but you need and extra pin and some extra logic. The clk and data will work the same and Slave Select can be used to enable/disable the 595. The 595 however, being not a 'true' SPI device, will still require the data to be latched to the register outputs. It's better, I think, just to soft send the data. Using the in-built functions are slow. I recently did some tests (see other posts) that showed using shiftout() to process a byte to a 595 took just under 45us, but a few tweaks/bypasses dropped this to just under 7us. This means that soft pushing a byte can realize speeds just over 1Mbps. Enough I think.