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

Sometimes receiving the packages I am sending over ESB

I am using ESB to send package from a nrf52832 (primary transmitter) to a nrf42840 (primary receiver). I use nrf5 SDK v15.3 on both of them. I send a ping message (12 bytes) every 10ms from the primary transmitter using tmsi_esb_ptx_send command. however somehow once in every 180 or so ping messages I send, I receive the ping message I send. This happens even if I remove the power the primary receiver.

I am using the following code for the callback function that get's called when the ping message is send.

static void nrf_esb_event_handler(nrf_esb_evt_t const * p_event)
{
    int foobar;
    switch (p_event->evt_id)
    {
        case NRF_ESB_EVENT_TX_SUCCESS:
            (*tmsi_esb_ptx_tx_succes)();
            break;
        case NRF_ESB_EVENT_TX_FAILED:
            (void) nrf_esb_flush_tx();
            (void) nrf_esb_start_tx();
            (*tmsi_esb_ptx_tx_failed)();
            break;
        case NRF_ESB_EVENT_RX_RECEIVED:
            foobar = 1;
            nrf_esb_payload_t rx_payload;
            //NRF_LOG_DEBUG("RX RECEIVED EVENT");
            while (nrf_esb_read_rx_payload(&rx_payload) == NRF_SUCCESS)
            {
                if (rx_payload.length > 0)
                {
                    (*tmsi_esb_ptx_rx_received)(&rx_payload);
                }
            }
            break;
    }
}

I have absolutely no idea how this could happen. Does maybe one of you have a clue?

Best regards,

Martijn

Parents
  • Hi Martijn, 

    So if I understand correctly, you get a NRF_ESB_EVENT_RX_RECEIVED after sending 180 ping messages eventhough the receiving device is not powered?

    Best regards

    Bjørn

  • Ok, could you post your esb configuration, i.e. the esb_init function?

    uint32_t esb_init( void )
    {
        uint32_t err_code;
        uint8_t base_addr_0[4] = {0xE7, 0xE7, 0xE7, 0xE7};
        uint8_t base_addr_1[4] = {0xC2, 0xC2, 0xC2, 0xC2};
        uint8_t addr_prefix[8] = {0xE7, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };
    
    #ifndef NRF_ESB_LEGACY
        nrf_esb_config_t nrf_esb_config         = NRF_ESB_DEFAULT_CONFIG;
    #else // NRF_ESB_LEGACY
        nrf_esb_config_t nrf_esb_config         = NRF_ESB_LEGACY_CONFIG;
    #endif // NRF_ESB_LEGACY
        nrf_esb_config.retransmit_count         = 6;
        nrf_esb_config.selective_auto_ack       = false;
        nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
        nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
        nrf_esb_config.event_handler            = nrf_esb_event_handler;
        nrf_esb_config.mode                     = NRF_ESB_MODE_PTX;
    
        err_code = nrf_esb_init(&nrf_esb_config);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_0(base_addr_0);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_1(base_addr_1);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_prefixes(addr_prefix, 8);
        VERIFY_SUCCESS(err_code);
    
        tx_payload.length  = 3;
        tx_payload.pipe    = 0;
        tx_payload.data[0] = 0x00;
    
        return NRF_SUCCESS;
    }

  • yes, my I initialise the esb primary transmitter using the following function:

    ret_code_t tmsi_esb_ptx_init(void (*esb_ptx_rx_received)(nrf_esb_payload_t *rx_payload), void (* esb_ptx_tx_succes)(), void (* esb_ptx_tx_failed)()){
        tmsi_esb_ptx_rx_received = esb_ptx_rx_received;
        tmsi_esb_ptx_tx_succes = esb_ptx_tx_succes;
        tmsi_esb_ptx_tx_failed = esb_ptx_tx_failed;
    
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART = 1;
    
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    
        uint32_t err_code;
    
        
        nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
        nrf_esb_config.retransmit_delay         = 600;
        nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
        nrf_esb_config.event_handler            = nrf_esb_event_handler;
        nrf_esb_config.mode                     = NRF_ESB_MODE_PTX;
        nrf_esb_config.selective_auto_ack       = false;
        nrf_esb_config.payload_length           = 252;
        nrf_esb_config.retransmit_count         = ESB_RETRANSMITS;
        
        tmsi_esb_set_tx_power(ESB_TX_POWER,0);
    
        err_code = nrf_esb_init(&nrf_esb_config);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_0(base_addr_0);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_1(base_addr_1);
        VERIFY_SUCCESS(err_code);
    
        err_code = tmsi_esb_set_rf_channel(ESB_RF_CHANNEL);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_prefixes(addr_prefix, NRF_ESB_PIPE_COUNT);
        VERIFY_SUCCESS(err_code);
        
        return err_code;
    }

Reply
  • yes, my I initialise the esb primary transmitter using the following function:

    ret_code_t tmsi_esb_ptx_init(void (*esb_ptx_rx_received)(nrf_esb_payload_t *rx_payload), void (* esb_ptx_tx_succes)(), void (* esb_ptx_tx_failed)()){
        tmsi_esb_ptx_rx_received = esb_ptx_rx_received;
        tmsi_esb_ptx_tx_succes = esb_ptx_tx_succes;
        tmsi_esb_ptx_tx_failed = esb_ptx_tx_failed;
    
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
        NRF_CLOCK->TASKS_HFCLKSTART = 1;
    
        while (NRF_CLOCK->EVENTS_HFCLKSTARTED == 0);
    
        uint32_t err_code;
    
        
        nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
        nrf_esb_config.retransmit_delay         = 600;
        nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
        nrf_esb_config.event_handler            = nrf_esb_event_handler;
        nrf_esb_config.mode                     = NRF_ESB_MODE_PTX;
        nrf_esb_config.selective_auto_ack       = false;
        nrf_esb_config.payload_length           = 252;
        nrf_esb_config.retransmit_count         = ESB_RETRANSMITS;
        
        tmsi_esb_set_tx_power(ESB_TX_POWER,0);
    
        err_code = nrf_esb_init(&nrf_esb_config);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_0(base_addr_0);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_base_address_1(base_addr_1);
        VERIFY_SUCCESS(err_code);
    
        err_code = tmsi_esb_set_rf_channel(ESB_RF_CHANNEL);
        VERIFY_SUCCESS(err_code);
    
        err_code = nrf_esb_set_prefixes(addr_prefix, NRF_ESB_PIPE_COUNT);
        VERIFY_SUCCESS(err_code);
        
        return err_code;
    }

Children
Related