This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to configure nrf24l01+ to send 1 byte payloads to nrf52840DK

I want to send a one byte payload from the nrf24l01+ (Sparkfun dev board), to nrf52840 DK using the example esb_prx. How should I configure the nrf24 registers to make this happen? Also, what changes do I have to make in the esb_prx example? I've been trying for quite a long time now. I use GCC to compile and program using nrfconnect.

EDIT: Really my preference would be to do this without the SDK, using only the RADIO peripheral. Here is my configuration of the radio:

// TODO incorrect logic for clearing bits
void radio_config(void)
{   
    // power on the radio peripheral
    *((uint32_t *)(RADIO_BASE + RADIO_POWER)) = 0;
    *((uint32_t *)(RADIO_BASE + RADIO_POWER)) = 1;

    *((uint32_t *)(RADIO_BASE + RADIO_FREQUENCY)) = 2;

    // no shorts
    *((uint32_t *)(RADIO_BASE + RADIO_SHORTS)) = 0;

    // tx output power
    *((uint32_t *)(RADIO_BASE + RADIO_TXPOWER)) = 0x8; // 8 dBm

    // Nordic 1 Mbit mode
    *((uint32_t *)(RADIO_BASE + RADIO_MODE)) = 0; 

    // Configure the address
    *((uint32_t *)(RADIO_BASE + RADIO_PREFIX0)) = 0xE7;
    *((uint32_t *)(RADIO_BASE + RADIO_BASE0)) = 0xE7E7E7E7;
    *((uint32_t *)(RADIO_BASE + RADIO_RXADDRESSES)) = 1; // enable reception on addr 0

    // LFLEN=6, S0LEN=0, S1LEN=3, S1INCL=1, CILEN=0, PLEN=0, CRCINC=0, TERMLEN=0
    *((uint32_t *)(RADIO_BASE + RADIO_PCNF0)) =
        (6 << RADIO_PCNF0_LFLEN) | (0 << RADIO_PCNF0_S0LEN) |
        (3 << RADIO_PCNF0_S1LEN) | (1 << RADIO_PCNF0_S1INCL) |
        (0 << RADIO_PCNF0_CILEN) | (0 << RADIO_PCNF0_PLEN) |
        (0 << RADIO_PCNF0_CRCINC) | (0 << RADIO_TERMLEN);
    
    // MAXLEN=32, STALEN=0, BALEN=4, ENDIAN=(0?), WHITEEN=(0?)
    // *((uint32_t *)(RADIO_BASE + RADIO_PCNF1)) = 0x00040040;
    *((uint32_t *)(RADIO_BASE + RADIO_PCNF1)) = 
        (32 << RADIO_PCNF1_MAXLEN) | (0 << RADIO_PCNF1_STATLEN) | 
        (4 << RADIO_PCNF1_BALEN) | (0 << RADIO_PCNF1_ENDIAN) |
        (0 << RADIO_PCNF1_WHITEEN);

    // interframe spacing
    *((uint32_t *)(RADIO_BASE + RADIO_TIFS)) = 150;
    
    // y = x8+x2+x+1
    *((uint32_t *)(RADIO_BASE + RADIO_CRCPOLY)) =
        (1 << 8) | (1 << 2) | (1 << 1) | (1 << 0);

    // LEN=1, SKIPADDR=0
    *((uint32_t *)(RADIO_BASE + RADIO_CRCCNF)) = 1;
    
    // initial = 0xFF
    *((uint32_t *)(RADIO_BASE + RADIO_CRCINIT)) = 0xFF;
    
    // // store EASYDMA_BASE address in PACKETPTR register
    *((uint32_t *)(RADIO_BASE + RADIO_PACKETPTR)) = (uint32_t)RADIO_DMA_BASE;
    
}

And here is my configuration on the nRF24L01+:

CONFIG: 0x5a
EN_AA: 0x01
EN_RXADDR: 0x01
SETUP_AW: 0x03
SETUP_RETR: 0x01
RF_CH: 0x02
RF_SETUP: 0x06
STATUS: 0x0e
OBSERVE_TX: 0x00
RPD: 0x00
RX_ADDR_P0: 0xe7e7e7e7e7
RX_ADDR_P1: 0xc2c2c2c2c2
RX_ADDR_P2: 0xc3
RX_ADDR_3: 0xc4
RX_ADDR_P4: 0xc5
RX_ADDR_P5: 0xc6
TX_ADDR: 0xe7e7e7e7e7
RX_PW_P0: 0x01
RX_PW_P1: 0x00
RX_PW_P2: 0x00
RX_PW_P3: 0x00
RX_PW_P4: 0x00
RX_PW_P5: 0x00
FIFO_STATUS: 0x11
DYNPD: 0x00
FEATURE: 0x01

Parents
  • Hello Kenneth,

    Thank you for assisting. I'll take a look at those, but I did specifically say that I don't want to use the SDK.  These appear to be links to the nRF5 SDK documentation. I get that I can use that, but I'd like to configure the radio peripheral so that I can accomplish this task bare metal, partially for educational purposes since I hope to use this part for various products which will use different RF protocols, including ESB, BLE, and protocols of my own design. How do the radio registers on the nRF52840 need to be configured for ESB?

    Thank you

    EDIT: Referring to Figure 37 in the nRF52840 product spec, it appears the the ADDRESS event is never received, even though the receiver is in the RXIDLE state, and the transmitter (nRF24) is sending payloads that do not require an ACK (the transmitter TX_DS interrupt IS triggering).

  • The ESB library contain the source files, I suggest to setup the radio using the ESB library, then either look at the initialization code and/or read out the registers after the radio is setup.

    Best regards,
    Kenneth

  • Hello again,

    I understand what you're saying, and I just want to respectfully state/reiterate:

    1) I've already tried using the the esb_prx from the NRF5 SDK, and couldn't get it working with the nRF24L01+.

    2) I just want a minimal register configuration for each device that would make them compatible to send just one byte, one time (low level register configuration please).

    I understand you may have some reservations about trusting the code snippet I gave for the nRF52, since you don't get to see the whole picture. From that perspective it makes sense to recommend I use the SDK. But if you can provide a register configuration for each device that works, then I will know that my code is the problem.

    Thank you

  • Hi,

    Maybe first verify that the esb_ptx and esb_prx works out of the box between two nRF52-DK's. Then you can also play around with various configuration (e.g. channel 2) and payload length = 1. 

    I am not aware of any issue that will prevent the esb_prx to receive data from nRF24L01+, provided you have set the compatibility mode as I described in my initial reply. Though you may compare your nRF24L01+ settings with the default settings in nRFgo SDK v2.3 that it's been tested with.

    Also check out this:
    https://devzone.nordicsemi.com/f/nordic-q-a/35482/nrf52832-not-working-with-nrf24l01-over-esb/136623#136623

    You may try to set DYNPD=1 and enable all features in FEATURE register of the nRF24L01+.

    Best regards,
    Kenneth

  • Hello,

    I've got successful transmissions between the nRF24l01+ (tx) and the nRF52840 (rx). I used my own code for the nRF24 with registers configured as shown:

    CONFIG: 0x5a
    EN_AA: 0x01
    EN_RXADDR: 0x01
    SETUP_AW: 0x03
    SETUP_RETR: 0x0f
    RF_CH: 0x02
    RF_SETUP: 0x06
    STATUS: 0x0e
    OBSERVE_TX: 0x0f
    RPD: 0x00
    RX_ADDR_P0: 0xe7e7e7e7e7
    RX_ADDR_P1: 0xc2c2c2c2c2
    RX_ADDR_P2: 0xc3
    RX_ADDR_3: 0xc4
    RX_ADDR_P4: 0xc5
    RX_ADDR_P5: 0xc6
    TX_ADDR: 0xe7e7e7e7e7
    RX_PW_P0: 0x00
    RX_PW_P1: 0x00
    RX_PW_P2: 0x00
    RX_PW_P3: 0x00
    RX_PW_P4: 0x00
    RX_PW_P5: 0x00
    FIFO_STATUS: 0x01
    DYNPD: 0x01
    FEATURE: 0x05

    And for the nRF52, I'm using the esb_rx example, with some changes to the configuration:

    nrf_esb_config_t nrf_esb_config         = NRF_ESB_LEGACY_CONFIG;
    nrf_esb_config.selective_auto_ack       = 1;
    nrf_esb_config.payload_length           = 12;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_1MBPS;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;

    However, I still haven't been able to configure the radio peripheral (bare metal) to get the same result. How can I get a register dump of the radio as configured in esb_rx? I tried using the NRF_LOG_DEBUG, but I can't get it to work. Any way I could view it in SES?

    Thank you

Reply
  • Hello,

    I've got successful transmissions between the nRF24l01+ (tx) and the nRF52840 (rx). I used my own code for the nRF24 with registers configured as shown:

    CONFIG: 0x5a
    EN_AA: 0x01
    EN_RXADDR: 0x01
    SETUP_AW: 0x03
    SETUP_RETR: 0x0f
    RF_CH: 0x02
    RF_SETUP: 0x06
    STATUS: 0x0e
    OBSERVE_TX: 0x0f
    RPD: 0x00
    RX_ADDR_P0: 0xe7e7e7e7e7
    RX_ADDR_P1: 0xc2c2c2c2c2
    RX_ADDR_P2: 0xc3
    RX_ADDR_3: 0xc4
    RX_ADDR_P4: 0xc5
    RX_ADDR_P5: 0xc6
    TX_ADDR: 0xe7e7e7e7e7
    RX_PW_P0: 0x00
    RX_PW_P1: 0x00
    RX_PW_P2: 0x00
    RX_PW_P3: 0x00
    RX_PW_P4: 0x00
    RX_PW_P5: 0x00
    FIFO_STATUS: 0x01
    DYNPD: 0x01
    FEATURE: 0x05

    And for the nRF52, I'm using the esb_rx example, with some changes to the configuration:

    nrf_esb_config_t nrf_esb_config         = NRF_ESB_LEGACY_CONFIG;
    nrf_esb_config.selective_auto_ack       = 1;
    nrf_esb_config.payload_length           = 12;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_1MBPS;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;

    However, I still haven't been able to configure the radio peripheral (bare metal) to get the same result. How can I get a register dump of the radio as configured in esb_rx? I tried using the NRF_LOG_DEBUG, but I can't get it to work. Any way I could view it in SES?

    Thank you

Children
Related