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

nrf24 as TX and nrf51 as RX: ESB

HI, I have a remote control with nRF24L01. It was talking with Gen1(uses nRF24L01) product via ESB. Now, I am developing Gen2 product*using nRF51822xxaa) and I need to support backwards compatibility with the remote control, in other words, I need to make nRF51 to talk with nRF24L01 via ESB. I am able to receive from nRF24L01(this means, address, crc, addr byte length are correct). But, when I send ack from nrf51 to nrf24 with payload, nrf24 is not receiving it. (when I use two nrf51s, one as tx and the other as rx, they both receive and transmit without any problems). Please help.

This is the init settings for nRF24L01:

hash define RF_CHANNEL      40 //physical channel frequency MHz (2400+RF_CHANNEL)

hash define RF_POWER_DB     3   //0:-18dBm, 1:- 12dBm, 2:-6dBm, 3:0dBm

hash define RF_ADDR_WIDTH   4 //the address is 4 bytes

hash define RF_RETRANSMITS  6   //auto retransmit

hash define RF_RETRANS_DELAY 750    //wait for the ACK (us)

hash  define BROADCAST_ADDR_BYTE1   0x7E

hash define BROADCAST_ADDR_BYTE2    0x7E

hash define BROADCAST_ADDR_BYTE3    0x7E

hash define BROADCAST_ADDR_BYTE4    0x6E

    // Enable the radio clock
    RFCKEN = 1;

    //close all pipes
    hal_nrf_close_pipe(HAL_NRF_ALL);
addr[RF_ADDR_WIDTH] = {BROADCAST_ADDR_BYTE1, BROADCAST_ADDR_BYTE2, BROADCAST_ADDR_BYTE3, BROADCAST_ADDR_BYTE4};

    hal_nrf_set_address(HAL_NRF_TX, addr); 

    hal_nrf_set_address(HAL_NRF_PIPE0, addr); 

    // Set rf channel 2430
    hal_nrf_set_rf_channel(RF_CHANNEL);

    // Set the RF_SETUP register
    hal_nrf_set_output_power(RF_POWER_DB); 
    //hal_nrf_set_datarate(HAL_NRF_1MBPS); //1Mbps data rate    
    hal_nrf_set_datarate(HAL_NRF_250KBPS);

    // Set CRC16
    hal_nrf_set_crc_mode(HAL_NRF_CRC_16BIT);    

    // Set address width
    hal_nrf_set_address_width(RF_ADDR_WIDTH); 

    // Set auto retries(ARC) and delay(ARD, us)
    hal_nrf_set_auto_retr(RF_RETRANSMITS, RF_RETRANS_DELAY);

    // Enable payload with ack and Dynamic payload length
    hal_nrf_activate_features(); //this chip does not need activate, so the func is empty
    hal_nrf_enable_ack_payload(true);
    hal_nrf_enable_dynamic_payload(true);    //dynamic payload length

    // Enable Pipe0 Dynamic payload length 
    hal_nrf_setup_dynamic_payload(0x01);

    // Enable pipe0 with auto ack
    hal_nrf_open_pipe(HAL_NRF_PIPE0, true);

    // Set rx payload width to the number of bytes expected
    hal_nrf_set_rx_payload_width(HAL_NRF_PIPE0, RF_PAYLOAD_LENGTH);

    // Flush tx and rx fifo
    hal_nrf_flush_rx();
    hal_nrf_flush_tx();     


    // Configure radio as PTX  
    hal_nrf_set_operation_mode(HAL_NRF_PTX);

    // Power up radio
    hal_nrf_set_power_mode(HAL_NRF_PWR_UP);

    ptx_check_ack.enable = false;


**This is the init settings for nRF51822xxaa:**

    (void)nrf_esb_init(NRF_ESB_MODE_PRX);

nrf_esb_set_crc_length(NRF_ESB_CRC_LENGTH_2_BYTE);

nrf_esb_set_datarate(NRF_ESB_DATARATE_250_KBPS);

nrf_esb_set_retransmit_delay(2750);

nrf_esb_set_base_address_length(NRF_ESB_BASE_ADDRESS_LENGTH_3B);

nrf_esb_set_address_prefix_byte(0, 0x7e);

nrf_esb_set_base_address_0(0x006e7e7e);

 nrf_esb_set_channel(40);

    // Load data into TX queue
 my_tx_payload[0] = 0xEF;
my_tx_payload[1] = 0xEF;
my_tx_payload[2] = 0xEF;
my_tx_payload[3] = 0xEF;
my_tx_payload[4] = 0xEF;
my_tx_payload[5] = 0xEF;
my_tx_payload[6] = 0xEF;
my_tx_payload[7] = 0xEF;
my_tx_payload[8] = 0xEF;
my_tx_payload[9] = 0xEF;
my_tx_payload[10] = 0xEF;
my_tx_payload[11] = 0xEF;


    (void)nrf_esb_add_packet_to_tx_fifo(PIPE_NUMBER, my_tx_payload, 12, NRF_ESB_PACKET_USE_ACK);

    (void)nrf_esb_add_packet_to_tx_fifo(PIPE_NUMBER, my_tx_payload, 12, NRF_ESB_PACKET_USE_ACK);

    (void)nrf_esb_add_packet_to_tx_fifo(PIPE_NUMBER, my_tx_payload,12, NRF_ESB_PACKET_USE_ACK);


    // Enable ESB to start receiving
    (void)nrf_esb_enable();
Parents
  • @nordicdev: On the other way around can you send ack payload from the nRF24L01 to the nRF51 ? I would suggest you to test with the latest SDK v11, where we have the ESB library open source. You can actually debug inside the nRF51 when it receive a packet to see what would be wrong with the ACK TX packet. You can then compare it with the TX packet when the nRF51 acts as PTX (that works fine).

Reply
  • @nordicdev: On the other way around can you send ack payload from the nRF24L01 to the nRF51 ? I would suggest you to test with the latest SDK v11, where we have the ESB library open source. You can actually debug inside the nRF51 when it receive a packet to see what would be wrong with the ACK TX packet. You can then compare it with the TX packet when the nRF51 acts as PTX (that works fine).

Children
No Data
Related