2

My end goal is to read information from an nRF24l01 module connected to my Arduino UNO R3, and generate an interrupt whenever a message is sent to the Arduino.

Now, I have read that for Hardware interrupts, only pins D2 and D3 can be used to generate interrupts. However, while connecting the MISO line, I saw that here it was mentioned that

On some Arduino boards (see table above), pins MOSI, MISO and SCK are the same pins as digital pin 11, 12 and 13, respectively. That is why many tutorials instruct you to hook up the target to these pins.

On every website I have searched, MISO is always connected to 12. Is there any way to change the MISO line from 12 to 3, or will I have to resort to using Pin change interrupts? Another way I can think of to bypass this is to connect D12 to D3, but I'm afraid this may cause complications in the circuit.

2 Answers2

1

I have read that for Hardware interrupts, only pins D2 and D3 can be used to generate interrupts

The pin-change interrupts, available on all pins of the Arduino Uno, are almost as good. I say "almost" because the only thing you have to do is work out which pin caused the interrupt, which can be trivial if you only set up one pin to generate interrupts.

Is there any way to change the MISO line from 12 to 3,

Not if you used the hardware SPI on the chip. If you use bit-banged SPI you can use any pins.

I did a project for a temperature and humidity sensor, which logs to a SD card (using SPI), and also displays on a 8-digit display (using SPI). For the latter case I used bit-banged SPI, as described there.

I have a page about SPI and also a similar one on Stack Exchange.

My bit-banged SPI code is available here.


I'm not clear about why you don't just use the hardware SPI pins. Is that you want an interrupt when a SPI message arrives? There is a hardware interrupt for just that. See my posts about SPI for more details about that.

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125
1

My second answer ...

Your question, in bold, is a good example of an XY Problem. You asked:

Is there any way to change the MISO line from 12 to 3, or will I have to resort to using Pin change interrupts?

This is the X question. However the Y question is your goal:

My end goal is to read information from an nRF24l01 module connected to my Arduino UNO ...

I answered, in another answer, first about changing the MISO line from pin 12, and also pointed out that SPI transactions can generate interrupts.

However, as Juraj pointed out in a comment, the Arduino in this case is the master and the nRF24l01 is the slave (from the SPI point of view).

There is no way that a slave can burst into life and generate a message, and hence cause an interrupt. That is the master's job.

As I read on this page about the module it has an IRQ pin described thus:

IRQ is an interrupt pin that can notify the master when there is new data to process.

So, your job is simplified, really. You don't need to detect when an SPI transaction starts (the Arduino will start the transaction), you need to connect the IRQ pin to an Arduino pin and detect that data is ready. Simple! Then you can easily use pin 2 or pin 3 if you want to use the "hardware" interrupts rather than the pin-change interrupts. (The pin-change interrupts are hardware interrupts too, though).

Nick Gammon
  • 38,901
  • 13
  • 69
  • 125