Example: confidence

nRF24L01 Tutorial 0 - diyembedded.com

Tutorial 0: Everything You Need to Know about the nRF24L01 and MiRF-v2. Written by Brennen Ball, 2007. Introduction So you think that getting a wireless connection between two or more microcontrollers is hard, eh? Well, it definitely can be if you're using certain hardware. I'm going to show you that it's not hard or expensive to set up a quality wireless link. You'll wonder why you ever used cables! Enter the nRF24L01 GHz wireless chip from our friends at Nordic Semiconductor. This chip was released a few years ago and is the successor to the popular nRF2401 series of chips. The 24L01 takes all of the good features of the 2401. and adds a true SPI interface, hardware link layer, multiple pipelines, and more. Plus, the chip is cheaper than your average microcontroller, and it doesn't require too many external components.

still some sections that I don’t describe in great detail because it is blatantly spelled out in the datasheet (register definitions in particular).

Tags:

  Tutorials, Nrf24l01, Nrf24l01 tutorial 0

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of nRF24L01 Tutorial 0 - diyembedded.com

1 Tutorial 0: Everything You Need to Know about the nRF24L01 and MiRF-v2. Written by Brennen Ball, 2007. Introduction So you think that getting a wireless connection between two or more microcontrollers is hard, eh? Well, it definitely can be if you're using certain hardware. I'm going to show you that it's not hard or expensive to set up a quality wireless link. You'll wonder why you ever used cables! Enter the nRF24L01 GHz wireless chip from our friends at Nordic Semiconductor. This chip was released a few years ago and is the successor to the popular nRF2401 series of chips. The 24L01 takes all of the good features of the 2401. and adds a true SPI interface, hardware link layer, multiple pipelines, and more. Plus, the chip is cheaper than your average microcontroller, and it doesn't require too many external components.

2 So what is my motivation for doing this? I don't work for Nordic or Sparkfun or any other company mentioned in this document. I really just do this because I like these transceivers and I would like to see more people use them. I hope that these tutorials help you in your quest for wirelessness! Background Information This document is essentially background information for the chip itself. I have included explanations of as many things as I could think of, as well as some suggestions for settings and operations. If you would like to skip directly to the Tutorial -related information, please this Tutorial and move on to Tutorial 2. However, if you are a beginner with this device, it would almost certainly help you to at least skim through the background sections of this Tutorial .

3 If anything, keep it around for future reference when you need suggestions or help on certain parts of your quest to the world's coolest new widget! Required Reading Yes, I know it sounds like a homework assignment, but you have to do it. If you're going to be successful with this little venture, you absolutely have to know your microcontroller, and have a copy of the datasheet/user manual either on paper or in digital format on your machine. Also, you should have the schematic for the PCB/breakout board that you have your micro on. For the 24L01, you absolutely have to download a copy of the datasheet ( )! While I will attempt to instruct you to the point that you don't have to have it, there are still some sections that I don't describe in great detail because it is blatantly spelled out in the datasheet (register definitions in particular).

4 Finally, if you have a breakout of the 24L01, such as the MiRF-v2, you also need to obtain the schematic and the datasheet/user manual for it. nRF24L01 Hardware Interface More than likely, you are using a breakout for the 24L01 of some sort. If so, you will likely have eight pins to interface with, and these are Vcc, GND, IRQ, CE, and the four SPI-related pins (CSN, SCK, MISO, and MOSI). If you are dealing with the bare chip, then I would suggest looking at the example circuit which can be found in Figure 13. of the datasheet, as I will not be discussing the use of any pins besides the eight just listed. Note: some of this information may be covered again as necessary in different sections. Thankfully for us, the guys at Nordic made the IO pins 5V-tolerant, which means you can run your microcontroller at 5V and it won't fry this chip.

5 Remember, though, that you can't run the 24L01 at 5V the data sheet gives an operating range of to for Vcc (the chip will be run at in most circumstances). The SPI interface uses four pins, CSN, SCK, MISO, and MOSI for data transmission and reception. The CSN (chip select not) pin is active-low, and is normally kept high. When this pin goes low, the 24L01 begins listening on its SPI port for data and processes it accordingly. The remaining three pins should be tied to the user's hardware SPI interface, to the same pins as their name suggests (SCK to SCK, MISO to MISO, and MOSI to MOSI). The remaining two pins are CE and IRQ. CE is used to control data transmission and reception when in TX and RX modes, respectively. IRQ is the interrupt pin, and is active-low.

6 There are three internal interrupts that can cause this pin to go low when they are active. Each of these bits can be masked out such that when the bit's respective interrupt becomes active, the status of the IRQ pin is not changed. A Closer Look at the MiRF-v2 Breakout of the nRF24L01 . For this Tutorial , I will be describing the MiRF-v2 breakout of the nRF24L01 that is available from Sparkfun Electronics ( ). These boards essentially give you all the supporting circuitry to get the link operating (matching network, clock, voltage regulator, and antenna/antenna jack) so that you don't have to lay out your own board. There is another flavor of this board (the MiRF-v2 RP-SMA) from Sparkfun that gives you a coax jack to connect an antenna to (both units pictured in Figure 1 on the following page).

7 I bought the plain MiRF-v2 board before the RP-SMA version came out, and it is considerably more expensive ($30 versus $15), but it does come with an on- board antenna. Other than the price, the other disadvantage of the plain MiRF-v2 is that it has considerably shorter range because the antenna runs over a ground trace. Either version will work, but don't forget that if you buy the RP-SMA version, you also have to buy an antenna for it. Not surprisingly, the guys at Sparkfun sell those, too, for around $7. Figure 1. Left to right: MiRF-v2 top, MiRF-v2 RP-SMA top and bottom (pics from ). Let's start out by looking at the pins we have on the MiRF-v2 board. If you don't have a MiRF-v2, this will still be helpful because the pins I describe are named the same as they are on the 24L01 chip itself.

8 Starting at the top, you have Vcc. This pin is connected to the input of a voltage regulator, and can handle to 7 Vdc per Sparkfun's website. I personally connect it to because that's the main power rail that I use with my microcontroller. Note: if you aren't using the MiRF-v2, then you should run to the Vcc pin, unless otherwise noted. The second pin down is the CE pin. This pin is always an input with respect to the 24L01. This pin has different meanings depending on what mode the 24L01 is in at a given time. First we assume that the device is powered-up internally (by setting the PWR_UP bit in the CONFIG register details on how to do that later). If the device is a receiver, having CE high allows the 24L01 to monitor the air and receive packets.

9 CE. being low puts the chip in standby and it no longer monitors the air. If the device is a transmitter, CE is always held low except when the user wants to transmit a packet. This is done by loading the TX FIFO and then toggling the CE pin (low-to-high transition, leave high for at least 10 uS, then back to low). The third pin is CSN, which stands for chip select not. This is the enable pin for the SPI bus, and it is active low (hence the not in the name). You always want to keep this pin high except when you are sending the device an SPI command or getting data on the SPI bus from the chip. The fourth pin from the top is SCK, which is the serial clock for the SPI bus. When you configure your SPI bus, SCK should stay low normally (rising edges are active), and the clock samples data in the middle of data bits.

10 On my hardware, this configuration is represented by the values of the bits CPOL and CPHA in my microcontroller's SPI configuration register both being 0. Coming in fifth from the top is the MOSI pin. MOSI stands for master out, slave in, and from both the microcontroller's and the 24L01's perspectives, the master is the microcontroller and the slave is the 24L01. This is because the 24L01 never sends data without first being requested by the microcontroller. Essentially, this pin is the side of the bus on which the master (the microcontroller) sends data to the slave (the 24L01). It is also connected to the MOSI pin on your microcontroller's SPI interface. Up sixth is the MISO pin. This pin is like the MOSI pin, but backwards. MOSI.