Radio_PTX sample code gives error interrupts for ESB_PROTOCOL_ESB protocol

Hi,

I am software engineer working in Philips. 

I am trying to transmit 21 bytes of our payload data (fixed payload length).

I have the following configurations done for esb_initialize() function.

int esb_initialize(void)
{
    int err;
    /* These are arbitrary default addresses. In end user products
     * different addresses should be used for each set of devices.
     */
    uint8_t base_addr_0[4] = {0x99, 0x44, 0x99, 0x96};
    uint8_t base_addr_1[4] = {0x00, 0x00, 0x00, 0x00};
    uint8_t addr_prefix[8] = {0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

    struct esb_config config = ESB_DEFAULT_CONFIG;

    config.protocol = ESB_PROTOCOL_ESB;
    config.retransmit_delay = 600;
    config.bitrate = ESB_BITRATE_1MBPS;
    config.event_handler = event_handler;
    config.mode = ESB_MODE_PTX;
    config.selective_auto_ack = true;
    config.payload_length = 21;
    err = esb_init(&config);

    if (err) {
        return err;
    }
    err = esb_set_base_address_0(base_addr_0);
    if (err) {
        return err;
    }

    err = esb_set_base_address_1(base_addr_1);
    if (err) {
        return err;
    }

    err = esb_set_prefixes(addr_prefix, ARRAY_SIZE(addr_prefix));
    if (err) {
        return err;
    }

    tx_payload.noack = 1;
    return 0;
}
I am filling up the tx_payload structure with our payload data.
I have created a 1008microseconds timer and in the timer callback function I am transmitting the tx_payload.
void timer_callback(void const *arg)
{

    int err;

if((packet_ready == true)&&(packet_tx_done == false))
{
    esb_flush_tx();

    err = esb_write_payload(&tx_payload);
    if (err) {
        LOG_ERR("Payload write failed, err %d", err);
    }

    esb_flush_tx();
    packet_tx_done = true;

}

}
I also had to update the PCNF0 and PCNF1 registers to remove the "S0", "LF" and "S1" lengths from the packet fit our protocol as shown below.
static void update_rf_payload_format_esb(uint32_t payload_length)
{
#if 0  
    NRF_RADIO->PCNF0 = (1 << RADIO_PCNF0_S0LEN_Pos) |
               (0 << RADIO_PCNF0_LFLEN_Pos) |
               (1 << RADIO_PCNF0_S1LEN_Pos);
#endif
    /*Ajit change*/
    NRF_RADIO->PCNF0 = (0 << RADIO_PCNF0_S0LEN_Pos) |
               (0 << RADIO_PCNF0_LFLEN_Pos) |
               (0 << RADIO_PCNF0_S1LEN_Pos);
    //(" \r\n ** Inside update_rf_payload_format_esb_dpl, NRF_RADIO->PCNF0L: 0x%x ** \r\n",NRF_RADIO->PCNF0);
//Ajit Change
    NRF_RADIO->PCNF1 =
        (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
        (RADIO_PCNF1_ENDIAN_Big << RADIO_PCNF1_ENDIAN_Pos) |
        ((esb_addr.addr_length - 1) << RADIO_PCNF1_BALEN_Pos) |
        (payload_length << RADIO_PCNF1_STATLEN_Pos) |
        (payload_length << RADIO_PCNF1_MAXLEN_Pos);

}
But I getting the error message "TX FAILED EVENT" continuously from the below mentioned interrupt handler.
void event_handler(struct esb_evt const *event)
{
    ready = true;

    switch (event->evt_id) {
    case ESB_EVENT_TX_SUCCESS:
        LOG_DBG("TX SUCCESS EVENT");
        break;
    case ESB_EVENT_TX_FAILED:
        LOG_DBG("TX FAILED EVENT");
        break;
    case ESB_EVENT_RX_RECEIVED:
        printk("RX EVENT \r\n");
        while (esb_read_rx_payload(&rx_payload) == 0) {
            LOG_DBG("Packet received, len %d : "
                "0x%02x, 0x%02x, 0x%02x, 0x%02x, "
                "0x%02x, 0x%02x, 0x%02x, 0x%02x",
                rx_payload.length, rx_payload.data[0],
                rx_payload.data[1], rx_payload.data[2],
                rx_payload.data[3], rx_payload.data[4],
                rx_payload.data[5], rx_payload.data[6],
                rx_payload.data[7]);
        }
        break;
    }
}
However the "ESB_PROTOCOL_ESB_DPL" protocol works when without giving this error interrupt.
But for "ESB_PROTOCOL_ESB_DPL" protocol I had assigned the "PCNF1_STATLEN" and "PCNF1_MAXLEN" values as "21" which is our payload data length.
 
Please could you help me resolve this issue ASAP. We need this program for our application.
Thanks and regards,
Ajit S J
Parents Reply Children
No Data
Related