This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Simplest possible way to send/receive 3 bytes with nRF24L01+

Hi dear friends from Nordic Semi, I´m in great trouble trying to make these nRF24L01+ to work, one unit as a transmiter, and one unit as a receiver, it can be to send 3 bytes at a time. I once used the Italian Telecontrolli RXQ-2 modules, but it´s not more available on the market. So, the best,cheapest available product is yours. But, to get started with it is really difficult. I want to send three bytes at a time, and from many Internet posts about the product, and after studying your datasheet, I have found that i need to set up the modules like that :

For setting up the transmitter module:

  • CE low -Wait 10 microseconds

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0b00100000

  • Send SPI 0b00001110

  • CSN high

  • Wait 10 microseconds ; Configures the unit for TX_prime

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0x31

  • Send SPI 0x3

  • CSN high

  • Wait 10 microseconds ; Configures pipe0 buffer size to 3 bytes

  • CSN low

  • Send SPI 0b11100001

  • CSN high ; Flush TX

  • Wait 10 microseconds

  • CSN low

  • Send SPI 0b11100010

  • CSN high ; Flush RX

  • Wait 2 miliseconds

CE high

For the transmitting routine:

  • CE low

  • Wait 10 microseconds

  • CSN high

  • Wait 10 microseconds

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0xa0

  • Send SPI 3 bytes

  • Wait 10 microseconds

  • CSN high

  • CE high

  • Wait 10 milliseconds

  • CE low

  • Wait 10 microseconds

  • Return to main routine.

For setting up the receiver module:

  • CE low

  • Wait 10 microseconds

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0b00100000

  • Send SPI 0b00001111

  • CSN high

  • Wait 10 microseconds ; Configures the unit for RX_prime

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0x31

  • Send SPI 0x3

  • CSN high

  • Wait 10 microseconds ; Configures pipe0 buffer size to 3 bytes

  • CSN low

  • Send SPI 0b11100001

  • CSN high ; Flush TX

  • Wait 10 microseconds

  • CSN low

  • Send SPI 0b11100010

  • CSN high ; Flush RX

  • Wait 2 miliseconds CE high

For the receiving routine:

  • CE low

  • Wait 10 microseconds

  • CSN low

  • Wait 10 microseconds

  • Send SPI 0x27

  • Send SPI 0x70 ; Clean status

  • CSN high

  • Wait 10 microseconds

  • CE low

  • Send SPI 0x61

  • Send SPI 0xFF - Get from SPI byte 1

  • Send SPI 0xFF - Get from SPI byte 2

  • Send SPI 0xFF - Get from SPI byte 3

  • CSN high

  • Wait 10 microseconds

  • CE high

  • Wait 10 microseconds -Back to the main routine

Both units are adequately wired, and in close distance one to other. I am using PIC16F877, running at 4 MHz, and programming in Assembler. I consider the channel settings the reset default, and I think it does not need to be changed to make things just work. What else should I do to make these things work ? What are the SPI settings that I should use ? Is there any other command or routine that I should implement to get the stuff working ? Thank you very much in advance.

Fabio Leitao Rio de Janeiro, Brazil

  • Wait 10 microseconds
  • Return to main routine.
Parents
  • I am slightly missing the initialization part. Or maybe I just can't see it. Basically, you need to initialize both modules before any communication. I have found one of my experiments with nRF24L01 chips (it works but there can be mistakes, it was not thoroughly tested ... and yeah, it is not commented - but you can easily follow the commands using datasheet). I am posting it as a image to keep the formatting right.

    Initialization of TX:

    image description

    Transmit of 32 bytes payload stored in "buffer":

    image description

    Initialization of RX:

    image description

    Unfortunately I can't provide you with "tutorial" code for receive because it is wrapped in my original software and thus a bit difficult to read, but basically you need to read STATUS register periodically and check for bit 6 (RX_DR). Then, you can read the RX FIFO - it is really easy, similar to transmit.

    This is only "somehow-it-works" example. I was testing the range and performance with it and I needed to glue the parts of code as quickly as possible, in an hour or so. You will need to study the datasheet and adapt your code to your application.

Reply
  • I am slightly missing the initialization part. Or maybe I just can't see it. Basically, you need to initialize both modules before any communication. I have found one of my experiments with nRF24L01 chips (it works but there can be mistakes, it was not thoroughly tested ... and yeah, it is not commented - but you can easily follow the commands using datasheet). I am posting it as a image to keep the formatting right.

    Initialization of TX:

    image description

    Transmit of 32 bytes payload stored in "buffer":

    image description

    Initialization of RX:

    image description

    Unfortunately I can't provide you with "tutorial" code for receive because it is wrapped in my original software and thus a bit difficult to read, but basically you need to read STATUS register periodically and check for bit 6 (RX_DR). Then, you can read the RX FIFO - it is really easy, similar to transmit.

    This is only "somehow-it-works" example. I was testing the range and performance with it and I needed to glue the parts of code as quickly as possible, in an hour or so. You will need to study the datasheet and adapt your code to your application.

Children
No Data
Related