I have nrf24l01+ connected to arduino nano. I connect ce to 7 and csn to 8. Mosi,miso and clock to 11,12,13.

Radio works normally and all other pins works fine.

I read 2,3,4 pulled up pins and send stuff normally but when reading pin10 my program immediately stops or goes to somekind loop?

I didin't find that nrf library uses pin 10?

Using RF24 by TMRh20 version 1.1.3

I'm just beginner so tell me what i'm missing here :slight_smile:

Post a schematics and post your code. Read the how to use this forum sticky post.

Pin 10 is the Slave Select pin and must be set as OUTPUT to allow SPI to work as master. RTFM


Oh I see. Problem solved!

Thanks Robin2!

@Robin2: so you claim pin 10 has to be an output even when SS is configured to use a different pin?

It is, however, possible to use any pin as the Slave Select (SS) for the devices.
For example, the Arduino Ethernet shield uses pin 4 to control the SPI connection to the on-board SD card,
and pin 10 to control the connection to the Ethernet controller.

Quote from Reference/SPI

the SPI bus uses pin 10 (SS)

Note that even if you're not using the SS pin, it must remain set as an output; otherwise, the SPI interface can be put into slave mode, rendering the library inoperative.

Quotes from here:
Arduino SPI reference

@Robin2: so you claim pin 10 has to be an output even when SS is configured to use a different pin?

I believe that is correct.

It may be the difference between selecting the Slave on the other device (which can use any Arduino pin) and selecting Slave mode on the Arduino which is done with pin 10 as far as I know.


A look to the datasheet made it (at least for me) a little clearer.

19.3.2 Master Mode
When the SPI is configured as a Master (MSTR in SPCR is set), the user can determine the direction of the SS pin.
If SS is configured as an output, the pin is a general output pin which does not affect the SPI system.
Typically, the pin will be driving the SS pin of the SPI Slave.
If SS is configured as an input, it must be held high to ensure Master SPI operation. If the SS pin is driven low by
peripheral circuitry when the SPI is configured as a Master with the SS pin defined as an input, the SPI system
interprets this as another master selecting the SPI as a slave and starting to send data to it.
To avoid bus contention, the SPI system takes the following actions:

  1. The MSTR bit in SPCR is cleared and the SPI system becomes a Slave. As a result of the SPI becoming a Slave,
    the MOSI and SCK pins become inputs.
  2. The SPIF Flag in SPSR is set, and if the SPI interrupt is enabled, and the I-bit in SREG is set, the interrupt
    routine will be executed.
    Thus, when interrupt-driven SPI transmission is used in Master mode, and there exists a possibility that SS is
    driven low, the interrupt should always check that the MSTR bit is still set. If the MSTR bit has been cleared by
    a slave select, it must be set by the user to re-enable SPI Master mode.