Difference between revisions of "Protocol decoder:Nrf24l01"
Uwe Hermann (talk | contribs) m |
Uwe Hermann (talk | contribs) (Cosmetics/typos, add Resources section.) |
||
Line 13: | Line 13: | ||
}} | }} | ||
The '''nrf24l01''' protocol decoder supports the protocol spoken by the Nordic Semiconductor | The '''nrf24l01''' protocol decoder supports the protocol spoken by the Nordic Semiconductor [http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01 nRF24L01] and [http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P nRF24L01+] 2.4GHz transceiver chips. | ||
[http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01 | |||
[http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P nRF24L01+] 2.4GHz transceiver chips. | |||
== Hardware == | == Hardware == | ||
Modules with these chips can be purchased fairly inexpensive from various online marketplaces. | Modules with these chips can be purchased fairly inexpensive from various online marketplaces. Most (all?) have an 8-pin header with the following pinout: | ||
Most (all?) | |||
{| border="0" style="font-size: smaller" class="alternategrey sigroktable" | {| border="0" style="font-size: smaller" class="alternategrey sigroktable" | ||
|- | |- | ||
Line 59: | Line 57: | ||
|} | |} | ||
The chip has two chip select pins, | The chip has two chip select pins, "CE" used to control the standby mode, and "CSN" used for SPI communication. | ||
"CE" used to control the standby mode, | |||
and "CSN" used for SPI communication. | |||
== Protocol == | == Protocol == | ||
The chip uses the standard SPI protocol and pins (CSN, SCK, MOSI, MISO), with the additional CE (used to control the RX/TX and standby modes) and IRQ (used to inform the SPI master about the completion of a packet reception/transmission) signals. If the number of available pins of the master are | The chip uses the standard SPI protocol and pins (CSN, SCK, MOSI, MISO), with the additional CE (used to control the RX/TX and standby modes) and IRQ (used to inform the SPI master about the completion of a packet reception/transmission) signals. If the number of available pins of the master are scarce, the CE pin can be tied to VCC and the IRQ pin can be left open. Polling over SPI can be used instead. | ||
SPI commands can have variable length, the CSN signal has to stay low during the whole command, and then go high after the last byte. The first byte of a command defines the type of the command, the chip always outputs its internal status register at the beginning. The following bytes are dependent on the command type, can be register values to write into the chip or payload data to send, or empty bytes that are ignored if the command only reads the output of the chip. | SPI commands can have variable length, the CSN signal has to stay low during the whole command, and then go high after the last byte. The first byte of a command defines the type of the command, the chip always outputs its internal status register at the beginning. The following bytes are dependent on the command type, can be register values to write into the chip or payload data to send, or empty bytes that are ignored if the command only reads the output of the chip. | ||
Line 71: | Line 67: | ||
== Decoder == | == Decoder == | ||
The <tt>nrf24l01</tt> decoder stacks on top of the SPI decoder and decodes the commands to the chip and the responses of the chip, and also issues warnings for wrong/incomplete commands. | The <tt>nrf24l01</tt> decoder stacks on top of the [[Protocol decoder:spi|SPI decoder]] and decodes the commands to the chip and the responses of the chip, and also issues warnings for wrong/incomplete commands. | ||
Some decoded commands in [[PulseView]]: | Some decoded commands in [[PulseView]]: | ||
<gallery> | <gallery> | ||
File:NRF24L01 PD write register.png|<small>Decoded "Write Register" command.</small> | File:NRF24L01 PD write register.png|<small>Decoded "Write Register" command.</small> | ||
Line 81: | Line 78: | ||
[[sigrok-cli]] can be used to decode the capture in the following way: | [[sigrok-cli]] can be used to decode the capture in the following way: | ||
<small> | <small> | ||
$ '''sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \''' | |||
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ | '''-P spi:cs=rpi_CSN:clk=rpi_CLK:mosi=rpi_MOSI:miso=rpi_MISO,nrf24l01''' | ||
Cmd. R_REGISTER "CONFIG" | |||
Cmd. R_REGISTER "CONFIG" | Reg. STATUS = "\x0E" | ||
Reg. STATUS = "\x0E" | Reg. CONFIG = "\x08" | ||
Reg. CONFIG = "\x08" | Reg. STATUS = "\x0E" | ||
Reg. STATUS = "\x0E" | Cmd. W_REGISTER: CONFIG = "\x08" | ||
Cmd. W_REGISTER: CONFIG = "\x08" | Reg. STATUS = "\x0E" | ||
Reg. STATUS = "\x0E" | Cmd. W_REGISTER: RF_CH = "\x3E" | ||
Cmd. W_REGISTER: RF_CH = "\x3E" | Reg. STATUS = "\x0E" | ||
Reg. STATUS = "\x0E" | Cmd. W_REGISTER: RX_ADDR_P0 = "\x37\x67\x74\x36\x7E" | ||
Cmd. W_REGISTER: RX_ADDR_P0 = "\x37\x67\x74\x36\x7E" | Reg. STATUS = "\x0E" | ||
Reg. STATUS = "\x0E" | ... | ||
... | Cmd. R_RX_PAYLOAD | ||
Cmd. R_RX_PAYLOAD | Reg. STATUS = "\x40" | ||
Reg. STATUS = "\x40" | RX payload = "message #0" | ||
RX payload = "message #0" | |||
</small> | </small> | ||
It can be seen that the register values are hex encoded, while the payload data is, if possible, represented as ASCII characters. | It can be seen that the register values are hex encoded, while the payload data is, if possible, represented as ASCII characters. | ||
If only the payload is of interest, the '''<tt>tx-data</tt>''' and '''<tt>rx-data</tt>''' | If only the payload is of interest, the '''<tt>tx-data</tt>''' and '''<tt>rx-data</tt>''' annotation classes can be selected using the '''<tt>-A|--protocol-decoder-annotations</tt>''' option: | ||
<small> | <small> | ||
$ '''sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \''' | |||
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ | '''-P spi:cs=uc_CSN:clk=uc_CLK:mosi=uc_MOSI:miso=uc_MISO,nrf24l01 \''' | ||
'''-A nrf24l01=tx-data''' | |||
TX payload = "message #0" | |||
TX payload = "message #0" | TX payload = "message #1" | ||
TX payload = "message #1" | TX payload = "message #2" | ||
TX payload = "message #2" | TX payload = "message #3" | ||
TX payload = "message #3" | TX payload = "message #4" | ||
TX payload = "message #4" | TX payload = "message #5" | ||
TX payload = "message #5" | TX payload = "message #6" | ||
TX payload = "message #6" | TX payload = "message #7" | ||
TX payload = "message #7" | TX payload = "message #8" | ||
TX payload = "message #8" | TX payload = "message #9" | ||
TX payload = "message #9" | |||
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ | $ '''sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \''' | ||
'''-P spi:cs=rpi_CSN:clk=rpi_CLK:mosi=rpi_MOSI:miso=rpi_MISO,nrf24l01 \''' | |||
'''-A nrf24l01=rx-data''' | |||
RX payload = "message #0" | RX payload = "message #0" | ||
RX payload = "message #1" | RX payload = "message #1" | ||
RX payload = "message #2" | RX payload = "message #2" | ||
RX payload = "message #3" | RX payload = "message #3" | ||
RX payload = "message #4" | RX payload = "message #4" | ||
RX payload = "message #5" | RX payload = "message #5" | ||
</small> | </small> | ||
Warnings issued for erroneous commands: | Warnings issued for erroneous commands: | ||
<small> | <small> | ||
$ '''sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-test-missing-bytes.sr \''' | |||
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-test-missing-bytes.sr \ | '''-P spi:cs=CS:clk=CLK:mosi=MOSI:miso=MISO,nrf24l01''' | ||
Cmd. R_REGISTER "CONFIG" | |||
Cmd. R_REGISTER "CONFIG" | Reg. STATUS = "\x00" | ||
Reg. STATUS = "\x00" | missing data bytes | ||
missing data bytes | Cmd. W_TX_PAYLOAD_NOACK | ||
Cmd. W_TX_PAYLOAD_NOACK | Reg. STATUS = "\x00" | ||
Reg. STATUS = "\x00" | missing data bytes | ||
missing data bytes | |||
</small> | </small> | ||
== Resources == | |||
* [http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01 nordicsemi.com: nRF24L01] ([http://www.nordicsemi.com/eng/nordic/download_resource/8041/1/64576247 datasheet]) | |||
* [http://www.nordicsemi.com/eng/Products/2.4GHz-RF/nRF24L01P/ nordicsemi.com: nRF24L01+] ([http://www.nordicsemi.com/eng/nordic/download_resource/8765/2/88509159 datasheet]) | |||
* [https://github.com/search?q=nrf24l01&type=Repositories github.com: nrf24l01] (various nRF24L01(+) projects and examples) | |||
[[Category:Protocol decoder]] | [[Category:Protocol decoder]] | ||
[[Category:SPI]] | [[Category:SPI]] |
Revision as of 16:14, 3 August 2014
Name | nRF24L01(+) |
---|---|
Description | 2.4GHz transceiver chip |
Status | supported |
License | GPLv2+ |
Source code | decoders/nrf24l01 |
Input | spi |
Output | nrf24l01 |
Probes | — |
Optional probes | — |
The nrf24l01 protocol decoder supports the protocol spoken by the Nordic Semiconductor nRF24L01 and nRF24L01+ 2.4GHz transceiver chips.
Hardware
Modules with these chips can be purchased fairly inexpensive from various online marketplaces. Most (all?) have an 8-pin header with the following pinout:
Pin | Function |
---|---|
1 | GND |
2 | VCC |
3 | CE |
4 | CSN |
5 | SCK |
6 | MOSI |
7 | MISO |
8 | IRQ |
The chip has two chip select pins, "CE" used to control the standby mode, and "CSN" used for SPI communication.
Protocol
The chip uses the standard SPI protocol and pins (CSN, SCK, MOSI, MISO), with the additional CE (used to control the RX/TX and standby modes) and IRQ (used to inform the SPI master about the completion of a packet reception/transmission) signals. If the number of available pins of the master are scarce, the CE pin can be tied to VCC and the IRQ pin can be left open. Polling over SPI can be used instead.
SPI commands can have variable length, the CSN signal has to stay low during the whole command, and then go high after the last byte. The first byte of a command defines the type of the command, the chip always outputs its internal status register at the beginning. The following bytes are dependent on the command type, can be register values to write into the chip or payload data to send, or empty bytes that are ignored if the command only reads the output of the chip.
Decoder
The nrf24l01 decoder stacks on top of the SPI decoder and decodes the commands to the chip and the responses of the chip, and also issues warnings for wrong/incomplete commands.
Some decoded commands in PulseView:
sigrok-cli can be used to decode the capture in the following way:
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ -P spi:cs=rpi_CSN:clk=rpi_CLK:mosi=rpi_MOSI:miso=rpi_MISO,nrf24l01 Cmd. R_REGISTER "CONFIG" Reg. STATUS = "\x0E" Reg. CONFIG = "\x08" Reg. STATUS = "\x0E" Cmd. W_REGISTER: CONFIG = "\x08" Reg. STATUS = "\x0E" Cmd. W_REGISTER: RF_CH = "\x3E" Reg. STATUS = "\x0E" Cmd. W_REGISTER: RX_ADDR_P0 = "\x37\x67\x74\x36\x7E" Reg. STATUS = "\x0E" ... Cmd. R_RX_PAYLOAD Reg. STATUS = "\x40" RX payload = "message #0"
It can be seen that the register values are hex encoded, while the payload data is, if possible, represented as ASCII characters.
If only the payload is of interest, the tx-data and rx-data annotation classes can be selected using the -A|--protocol-decoder-annotations option:
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ -P spi:cs=uc_CSN:clk=uc_CLK:mosi=uc_MOSI:miso=uc_MISO,nrf24l01 \ -A nrf24l01=tx-data TX payload = "message #0" TX payload = "message #1" TX payload = "message #2" TX payload = "message #3" TX payload = "message #4" TX payload = "message #5" TX payload = "message #6" TX payload = "message #7" TX payload = "message #8" TX payload = "message #9"
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-communication.sr \ -P spi:cs=rpi_CSN:clk=rpi_CLK:mosi=rpi_MOSI:miso=rpi_MISO,nrf24l01 \ -A nrf24l01=rx-data RX payload = "message #0" RX payload = "message #1" RX payload = "message #2" RX payload = "message #3" RX payload = "message #4" RX payload = "message #5"
Warnings issued for erroneous commands:
$ sigrok-cli -i sigrok-dumps/spi/nrf24l01/nrf24l01-test-missing-bytes.sr \ -P spi:cs=CS:clk=CLK:mosi=MOSI:miso=MISO,nrf24l01 Cmd. R_REGISTER "CONFIG" Reg. STATUS = "\x00" missing data bytes Cmd. W_TX_PAYLOAD_NOACK Reg. STATUS = "\x00" missing data bytes
Resources
- nordicsemi.com: nRF24L01 (datasheet)
- nordicsemi.com: nRF24L01+ (datasheet)
- github.com: nrf24l01 (various nRF24L01(+) projects and examples)