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

Advice for simple communication from nrf51822 to nrf24l01 ?

Hi everyone ! I'm trying to send data from an nrf51822 to an nrf24l01 with arduino and I guess I'm doing something wrong...

For the moment I succeeded to have these talking together:

...so I guess the hardware is not the problem :) (if you're curious about the context, the project is explained here: hackster.io/cedric/twi)

I looked for similar problems on the forum but I don't find the solution to my problem, if anyone has a suggestion I would be infinitely grateful ;D

Here is the configuration I use:

nrf51 (TX): radio_config.c main.c

nrf24 (RX) with arduino: Mirf.cpp RX.ino

I used the nrf51 sdk suggestions and an nrf24 library (+datasheets) to understand it, but it doesn't work (yet!), the nrf24 reception pipe stays empty.

Anyone has any suggestion to offer ? Thanks a lot !! ;)

Parents
  • Hi Cedric,

    The nRF51 does not have the enhanced shockburst in hardware anymore, which means that when you send a payload from the nRF51 side, and the L01+ is configured to do auto-ACKing, you will run into issues.

    What I would suggest is that you use the ESB-library on the nRF51 side, and on the nRF24L-side you enable registers:

    • EN_DPL for your pipes.
    • EN_DYN_ACK
    • EN_ACK_PAY

    If you look at the ESB library documentation, there's a section on how the nRF24LE1 should be configured (see the nRFgo SDKs hal_nrf.c file for reference to the calls, its basically the registers I posted): devzone.nordicsemi.com/.../a00139.html

    Best regards Håkon

  • (3/3) Bare-bones of NRF51822 transmitting code:

    #include "micro_esb.h"
    

    #include "uesb_error_codes.h"

    static uesb_payload_t tx_payload, rx_payload;

    void uesb_event_handler() { static uint32_t rf_interrupts; static uint32_t tx_attempts;

    uesb_get_clear_interrupts(&rf_interrupts);
    
    if(rf_interrupts & UESB_INT_TX_SUCCESS_MSK)
    {   
    			ackd=true;
    	}
    
    if(rf_interrupts & UESB_INT_TX_FAILED_MSK)
    {
        uesb_flush_tx();
    }
    
    if(rf_interrupts & UESB_INT_RX_DR_MSK)
    {
        uesb_read_rx_payload(&rx_payload);
        NRF_GPIO->OUTCLR = 0xFUL << 8;
        NRF_GPIO->OUTSET = (uint32_t)((rx_payload.data[2] & 0x0F) << 8);
    }
    
    uesb_get_tx_attempts(&tx_attempts);
    NRF_GPIO->OUTCLR = 0xFUL << 12;
    NRF_GPIO->OUTSET = (tx_attempts & 0x0F) << 12;
    

    }

    int main(void) {

    // Put power up high for testing purposes
    uesb_set_tx_power(UESB_TX_POWER_4DBM);
    
    // Set receive address
    uint8_t rx_addr_p0[] = {0xD2, 0xF0, 0xF0, 0xF0, 0xF0};
    uint8_t rx_addr_p1[] = {0xE1, 0xF0, 0xF0, 0xF0, 0xF0};
    uint8_t rx_addr_p2   = 0x66;	
    
    // Start the high-frequency clock - we'll need it for the radio
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);	
    
    // Configure the radio
    uesb_config_t uesb_config       = UESB_DEFAULT_CONFIG;
    uesb_config.rf_channel          = 5;
    uesb_config.crc                 = UESB_CRC_16BIT;
    uesb_config.retransmit_count    = 6;
    uesb_config.retransmit_delay    = 500;
    uesb_config.dynamic_ack_enabled = true;
    uesb_config.protocol            = UESB_PROTOCOL_ESB_DPL;
    uesb_config.bitrate             = UESB_BITRATE_1MBPS;
    uesb_config.event_handler       = uesb_event_handler;
    
    uesb_init(&uesb_config);
    uesb_set_address(UESB_ADDRESS_PIPE0, rx_addr_p0);
    uesb_set_address(UESB_ADDRESS_PIPE1, rx_addr_p1);
    uesb_set_address(UESB_ADDRESS_PIPE2, &rx_addr_p2);
    
    // Load the payload with some dummy information
    tx_payload.length  = 13;
    tx_payload.pipe    = 0;
    tx_payload.data[0] = 0x01;
    tx_payload.data[1] = 0x02;
    tx_payload.data[2] = 0x03;
    tx_payload.data[3] = 0x04;
    
    
    while (true)
    {
    
    			// -------------- TRANSMIT ---------------------
    		
    			if(uesb_write_tx_payload(&tx_payload) == UESB_SUCCESS)
    			{
    					tx_payload.data[0]++;
    			}
    		
    			nrf_delay_ms(100);
    			
    		
    			
    }
    

    }

Reply
  • (3/3) Bare-bones of NRF51822 transmitting code:

    #include "micro_esb.h"
    

    #include "uesb_error_codes.h"

    static uesb_payload_t tx_payload, rx_payload;

    void uesb_event_handler() { static uint32_t rf_interrupts; static uint32_t tx_attempts;

    uesb_get_clear_interrupts(&rf_interrupts);
    
    if(rf_interrupts & UESB_INT_TX_SUCCESS_MSK)
    {   
    			ackd=true;
    	}
    
    if(rf_interrupts & UESB_INT_TX_FAILED_MSK)
    {
        uesb_flush_tx();
    }
    
    if(rf_interrupts & UESB_INT_RX_DR_MSK)
    {
        uesb_read_rx_payload(&rx_payload);
        NRF_GPIO->OUTCLR = 0xFUL << 8;
        NRF_GPIO->OUTSET = (uint32_t)((rx_payload.data[2] & 0x0F) << 8);
    }
    
    uesb_get_tx_attempts(&tx_attempts);
    NRF_GPIO->OUTCLR = 0xFUL << 12;
    NRF_GPIO->OUTSET = (tx_attempts & 0x0F) << 12;
    

    }

    int main(void) {

    // Put power up high for testing purposes
    uesb_set_tx_power(UESB_TX_POWER_4DBM);
    
    // Set receive address
    uint8_t rx_addr_p0[] = {0xD2, 0xF0, 0xF0, 0xF0, 0xF0};
    uint8_t rx_addr_p1[] = {0xE1, 0xF0, 0xF0, 0xF0, 0xF0};
    uint8_t rx_addr_p2   = 0x66;	
    
    // Start the high-frequency clock - we'll need it for the radio
    NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK->TASKS_HFCLKSTART = 1;
    while(NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);	
    
    // Configure the radio
    uesb_config_t uesb_config       = UESB_DEFAULT_CONFIG;
    uesb_config.rf_channel          = 5;
    uesb_config.crc                 = UESB_CRC_16BIT;
    uesb_config.retransmit_count    = 6;
    uesb_config.retransmit_delay    = 500;
    uesb_config.dynamic_ack_enabled = true;
    uesb_config.protocol            = UESB_PROTOCOL_ESB_DPL;
    uesb_config.bitrate             = UESB_BITRATE_1MBPS;
    uesb_config.event_handler       = uesb_event_handler;
    
    uesb_init(&uesb_config);
    uesb_set_address(UESB_ADDRESS_PIPE0, rx_addr_p0);
    uesb_set_address(UESB_ADDRESS_PIPE1, rx_addr_p1);
    uesb_set_address(UESB_ADDRESS_PIPE2, &rx_addr_p2);
    
    // Load the payload with some dummy information
    tx_payload.length  = 13;
    tx_payload.pipe    = 0;
    tx_payload.data[0] = 0x01;
    tx_payload.data[1] = 0x02;
    tx_payload.data[2] = 0x03;
    tx_payload.data[3] = 0x04;
    
    
    while (true)
    {
    
    			// -------------- TRANSMIT ---------------------
    		
    			if(uesb_write_tx_payload(&tx_payload) == UESB_SUCCESS)
    			{
    					tx_payload.data[0]++;
    			}
    		
    			nrf_delay_ms(100);
    			
    		
    			
    }
    

    }

Children
No Data
Related