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

Related