1 : PWR_UP : Power up control. [1 = Power up] [0 = Power
2 : CRCO : Set CRC encoding scheme. [1 = 2
Bytes] [0 = 1 Byte] I have a tutorial on CRC
if you dont know what it is.
3 : EN_CRC : Enables the CRC (more on this later) If any channel
has Auto Ack enabled the CRC is
also forced to be enabled. Ill explain why.
4 : MASK_MAX_RT : Enables/Disables whether the MAX_RT
interrupt drives the IRQ pin
5 : MASK_TX_DS : Enables/Disables whether the TX_DS interrupt drives the
6 : MASK_RX_DR : Enables/Disables whether the RX_DR interrupt drives the
Bits 0 and 1 are pretty self explanatory. Bit 2 controls how many bytes are
used for the CRC scheme, basically the NRF will add either 1 or 2 bytes at the
end of a transmission when CRC is enabled. And as noted when any channel has
auto acknowledge enabled the CRC is forced.
CRC and auto Ack work in conjunction to make sure data reception is only
presented when the data is valid. The NRF will run a CRC algorithm on the
address, packet control (if there is one) and your payload. The result of that
is a "CRC code" and it will add that code to the frame format and
transmit it along with your data. Then the transmitter will turn itself into a
receiver, no code required to do this, and listen for an ACK to verify the
data was received.
The receiver will receive the entire frame packet and extract your data and
run the same CRC algorithm on it. If the CRC code that results from the
receivers CRC engine is the same as the one sent by the transmitter then it
means they both ran the same CRC algorithm on the exact same data and thus no
bits were lost or modified or noise etc.. therefore the data is valid.
At this point the receiver will momentarily turn into a transmitter, all on
its own no code required, and it will send an ACK command to the transmitter
telling it that it received the data. If the CRC codes do not match then the
receiver does not send anything and discards the data.
Note that both receiver and transmitter need to have auto ACK enabled for this
scheme to work, this is what they call "Enhanced Shockburst" , see its just a
Bits 4 to 6 are used to mask (enable/disable) different interrupts from
affecting the IRQ pin. The IRQ pin is active low, when an interrupt happens
and it is not masked out by these bits, the pin will go LOW signaling an
interrupt condition has occurred and it would be up to software to then check
the status register to see which interrupt is the one that was
MASK_MAX_RT: (MAXIMUM RETRY)When the transmitter fails to receive an ACK from a receiver
with auto ACK enabled, it will attempt to re-transmit the packet a
specified number of times. Once that max number of tries is reached and
still no ACK is received then the MAX_RT interrupt bit is set in the
status register and if enabled by this bit the IRQ pin will go low.
MASK_TX_DS : (DATA SENT) This is used to mask the TX_DS from affecting the IRQ pin.
The TX_DS interrupt signals that the data packet has been sent. If auto
ACK is enabled then the interrupt will only trigger if the ACK is
MSK_RX_DR : (DATA RECEIVED) This bit is used to mask the RX_DR interrupt from affecting
the IRQ pin. The RX_DR interrupt signals that data has been received.
[ 1 = Interrupt has no effect on IRQ pin ] [ 0 =
Interrupt drives the IRQ pin low ]
Note that these bits are not the interrupts themselves, they only enable or
disable the those interrupts from affecting the IRQ pin. The interrupts will
happen no matter what and must be handled/cleared in order for the NRF to
keep doing its job. They are cleared by writing a 1 to them in the status register.
A normal ShockBurst (just a fancy name indicating CRC is enabled) frame format looks like this and as you can see the CRC
is added as the LSB
And if you are wondering, the Preamble is nothing more then a sequence of 1s
and 0s to synchronize the receiver's demodulator to the incoming stream. It is
only one byte long, if the first bit in the address is a 1 then the preamble
is 10101010, otherwise it is 01010101.
And here are the rest of the registers, their names are in blue as they appear in the datasheet and in my code , minus the "Register" word obviously..
0 - 5 : This bits are used to enable auto acknowledge on the given pipe
A "Pipe" is basically like a different channel but not a frequency channel,
think of it as the name suggest a Pipe. Imagine one big Pipe where all the
data comes through, this would be your frequency 2.4 Ghz give or take some
megahertz because you have the option to change the frequency channels. Your
data travels on this frequency and that is the BIG pipe so to speak. When it
gets to the receiver it now can go down several other small pipes each with
its own address. That is why when you transmit a data packet you send an
address. More on that later. Got it? Good!!
This register only uses 2bits to set the width of the pipe addresses.
The values allowed are as follow:
00 - Illegal
01 - 3 bytes
10 - 4 bytes
11 - 5 bytes
Remember that the address is transmitted every time you send a packet so
having less bytes to transmit can be beneficial in some applications but the
robustness of having more bytes may be useful in other applications.
This register uses bits 0 through 6 to set the channel frequency where your NRF will transmit and receive its data. Needless to say that both transmitter and receiver need to be on the same frequency. Also needless to say you get 126 RF channels to chose from. 000000 is not acceptable, hence why you dont have 127.
3 : RF_DR_HIGH : Select one of the high data rates : [ 0 = 1Mbps ] [ 1 = 2Mbps ]
4 : PLL_LOCK : This bit is used for testing . Not relevant for operation. Leave at reset value of 0
5 : RF_DR_LOW : Set the data rate to its lowest of 250kbs, if this is set it overrides RF_DR_HIGH
6 : RESERVED
7 : CONT_WAVE : This bit enables continuous transmission.
The RF_PWR and PLL_LOCK bits should for the most part be left alone. The PLL_LOCK bit is used for a testing procedure explained in the datasheet, you ca view that on your ow. The RF_PWR bit controls the output power, if you do not know anything about analog electronics, 0dBm does not mean zero output power. Unless you have power consumption restrictions to meet you should not really set it below 0dBm.
0-3 : ARC_CNT : These bits tell current count of re-transmit
4-7 : PLOS_CNT : These bits keep track of how many packets have been lost after the max re-transmit
When ARC_CNT exceeds the max number of re-transmits set in the SETUP_RETR register it triggers the MAX_RT interrupt , which in turn may or may not trigger the IRQ pin to go low depending on your settings.
If you look carefully, the image above depicts two registers, RX_ADDR_P0 and register RX_ADDR_P1. This does not mean there are two registers in one, I am simply stating that both RX_ADDR_P0 and RX_ADDR_P1 have up to 5bytes (40 bits) All these bits are used to set a unique address of your choice to Pipe 0 and Pipe 1. You do not have to use all 5 bytes but if you want to use 5 bytes these are the only two Pipes that support 5 byte of unique address space.
This register is also 5bytes (40bits) long, I just got lazy to draw it like I drew the other long register. In this register you enter the address that has to match the pipe address on the receiver that listening. It does not have to be 5bytes long, since some pipes only support at one byte addresses.
When you transmit data as a transmitter to a receiver, both must agree on the payload length otherwise the receiver will not acknowledge the received payload.
However this register allows you to send data of variable length without the need to have a predefined data width. each bit in this register enabled Dynamic Payload on a given pipe. However the Dynamic payload feature also must be enabled , in order for an individual pipe to also have dynamic payload. The feature is enabled in the next register.
1 : EN_ACK_PAY : Allows the receiver to also send a payload along with an AUTO ACK
2 : EN_DPL : Enables dynamic payload
The EN_DYN_ACK bit means that the receiver does not have to send an ACK and the transmitter is also not expecting one.
The auto ack sent by a receiver to tell the transmitter is usually does not include any payload , but you can do that if you would like by enabling the EN_ACK_PAY bit. And ultimately EN_DPL is self explanatory.
One thing not discussed here are the RX and TX FIFO registers, that is because they are not directly accessible and have no address listed. The data fetches from them are all done by the NRF hardware when you send a read or write command. And that is the topic of the next post... the NRF supported commands.