Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Issues using nrf_esb_set_rf_channel() to change frequency on nRF52 ESB

I'm using an nRF52 (PRX) to communicate with with an nRF24L01+ (PTX) using ESB. As part of a pairing routine they need to switch channel and addresses. I've confirmed that the nRF52 is receiving the correct frequency and address, but it still fails to change over correctly. It will work sometimes, but seemingly at random.

Could I get a quick code snippet showing how to properly change address and channel when the nRF52 is currently communicating? My current code looks like this

nrf_esb_disable();

tx_payload.length = 32;
uint32_t err_code;
nrf_esb_config_t nrf_esb_config         = NRF_ESB_LEGACY_CONFIG;
nrf_esb_config.payload_length           = 32;
nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
nrf_esb_config.crc                  	= NRF_ESB_CRC_16BIT;
nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
nrf_esb_config.event_handler            = nrf_esb_event_handler;
nrf_esb_config.selective_auto_ack       = false;

err_code = nrf_esb_init(&nrf_esb_config);
VERIFY_SUCCESS(err_code);
	
nrf_esb_stop_rx();
while(!nrf_esb_is_idle());
	
//Set frequency
err_code = nrf_esb_set_rf_channel(freq);
VERIFY_SUCCESS(err_code);
//Set rest of address
err_code = nrf_esb_set_base_address_0(base_addr_0);
VERIFY_SUCCESS(err_code);
//Set first byte of address
err_code = nrf_esb_set_prefixes(addr_prefix, 1);
VERIFY_SUCCESS(err_code);
	
//Check that we switched to the right frequency
uint32_t channel_data[6];
nrf_esb_get_rf_channel(channel_data);

err_code = nrf_esb_start_rx();
VERIFY_SUCCESS(err_code);
	

Parents
  • Hi,

     

    I am very sorry for the late reply.

    Are you still seeing this issue? If so, could you share the nRF24L-side configuration?

     

    Best regards,

    Håkon

  •     write_register_nrf24(0x00, 0b01001110); //all interrupts enabled except RX_DR, 2 byte CRC, power up, PTX
        write_register_nrf24(0x01, 0b00000001); //auto-ack enabled on data pipe 0
        write_register_nrf24(0x02, 0b00000001); //enable RX data pipe 0
        write_register_nrf24(0x03, 0b00000011); //5 byte addressing
        write_register_nrf24(0x04, 0b01010001); // enable retransmit 5 times, ARD=500us - ARD must be >= 500 when transmitting at 2 Mbps
    
        write_register_nrf24(0x05, STANDARD_PAIRING_CHANNEL); //Use +125MHz for pairing
    
        write_register_nrf24(0x06, 0b00001110); // 2 Mbps, max power
        write_register_nrf24(0x07, 0b00110000); // clear all interrupts
    
        outgoing_data_nrf24[0] = 0x20 | 0x0A; // pipe 0 RX address register
        outgoing_data_nrf24[1] = pairing_mode_address[0];
        outgoing_data_nrf24[2] = pairing_mode_address[1];
        outgoing_data_nrf24[3] = pairing_mode_address[2];
        outgoing_data_nrf24[4] = pairing_mode_address[3];
        outgoing_data_nrf24[5] = pairing_mode_address[4];
        write_byte_to_nrf24(6); // set Pipe 0 reciving address
    
        outgoing_data_nrf24[0] = 0x20 | 0x10; // pipe 0 TX address register
        outgoing_data_nrf24[1] = pairing_mode_address[0];
        outgoing_data_nrf24[2] = pairing_mode_address[1];
        outgoing_data_nrf24[3] = pairing_mode_address[2];
        outgoing_data_nrf24[4] = pairing_mode_address[3];
        outgoing_data_nrf24[5] = pairing_mode_address[4];
        write_byte_to_nrf24(6); // set Pipe 0 reciving address
    
        write_register_nrf24(0x11, 7); //7 byte packet for pairing mode
        write_register_nrf24(0x1C, 0b00000001); //enable dynamic payload length data pipe 0
        write_register_nrf24(0x1D, 0b00000110); //enable dynamic payload length, payload w/ ACK
    
        outgoing_data_nrf24[0] = 0b11100001; //flush TX
        write_byte_to_nrf24(1);
        outgoing_data_nrf24[0] = 0b11100010; //flush RX
        write_byte_to_nrf24(1);
    
        CE_SPI1 = 0; //disable the chip (CE stands for Chip enable) - for PTX mode

    Hi Hakon, yes still experiencing the problem. Here is my configuration code for the nRF24L side.

    To add some more detail about the system I have two modules that communicate over ESB, one PRX and one PTX. In the past both sides were nRF24 and worked reliably. I'm now trying to replace the PRX side with a nRF52. At startup they load the last used frequency and address from flash memory and start communicating. I have this much working with the nRF52. It starts up, receives a frequency and address from the main MCU over SPI, and starts communicating.

    The problem arises when I want to change the frequency and address. PTX picks frequency, PRX, picks address, they exchange info on a designated channel then resume normal operation. WIth two nRF24s this works fine but the nRF52 does not seem to switch either frequency or address successfully.

Reply
  •     write_register_nrf24(0x00, 0b01001110); //all interrupts enabled except RX_DR, 2 byte CRC, power up, PTX
        write_register_nrf24(0x01, 0b00000001); //auto-ack enabled on data pipe 0
        write_register_nrf24(0x02, 0b00000001); //enable RX data pipe 0
        write_register_nrf24(0x03, 0b00000011); //5 byte addressing
        write_register_nrf24(0x04, 0b01010001); // enable retransmit 5 times, ARD=500us - ARD must be >= 500 when transmitting at 2 Mbps
    
        write_register_nrf24(0x05, STANDARD_PAIRING_CHANNEL); //Use +125MHz for pairing
    
        write_register_nrf24(0x06, 0b00001110); // 2 Mbps, max power
        write_register_nrf24(0x07, 0b00110000); // clear all interrupts
    
        outgoing_data_nrf24[0] = 0x20 | 0x0A; // pipe 0 RX address register
        outgoing_data_nrf24[1] = pairing_mode_address[0];
        outgoing_data_nrf24[2] = pairing_mode_address[1];
        outgoing_data_nrf24[3] = pairing_mode_address[2];
        outgoing_data_nrf24[4] = pairing_mode_address[3];
        outgoing_data_nrf24[5] = pairing_mode_address[4];
        write_byte_to_nrf24(6); // set Pipe 0 reciving address
    
        outgoing_data_nrf24[0] = 0x20 | 0x10; // pipe 0 TX address register
        outgoing_data_nrf24[1] = pairing_mode_address[0];
        outgoing_data_nrf24[2] = pairing_mode_address[1];
        outgoing_data_nrf24[3] = pairing_mode_address[2];
        outgoing_data_nrf24[4] = pairing_mode_address[3];
        outgoing_data_nrf24[5] = pairing_mode_address[4];
        write_byte_to_nrf24(6); // set Pipe 0 reciving address
    
        write_register_nrf24(0x11, 7); //7 byte packet for pairing mode
        write_register_nrf24(0x1C, 0b00000001); //enable dynamic payload length data pipe 0
        write_register_nrf24(0x1D, 0b00000110); //enable dynamic payload length, payload w/ ACK
    
        outgoing_data_nrf24[0] = 0b11100001; //flush TX
        write_byte_to_nrf24(1);
        outgoing_data_nrf24[0] = 0b11100010; //flush RX
        write_byte_to_nrf24(1);
    
        CE_SPI1 = 0; //disable the chip (CE stands for Chip enable) - for PTX mode

    Hi Hakon, yes still experiencing the problem. Here is my configuration code for the nRF24L side.

    To add some more detail about the system I have two modules that communicate over ESB, one PRX and one PTX. In the past both sides were nRF24 and worked reliably. I'm now trying to replace the PRX side with a nRF52. At startup they load the last used frequency and address from flash memory and start communicating. I have this much working with the nRF52. It starts up, receives a frequency and address from the main MCU over SPI, and starts communicating.

    The problem arises when I want to change the frequency and address. PTX picks frequency, PRX, picks address, they exchange info on a designated channel then resume normal operation. WIth two nRF24s this works fine but the nRF52 does not seem to switch either frequency or address successfully.

Children
No Data
Related