ESB receive the data sent by itself

Hi all,

Question preconditions:

nRF52832, SDK 17.1.0, use FreeRTOS.

1 PTX and 2 PRX, PTX send heart beat to every PRX to receive the data from PRX.

Two PRX enable different pipe by nrf_esb_enable_pipes(bit_n).

.

Question.

I use the ESB to send data to two PRX every ms, when I use fixed data to accumulate and send it to PRX, It works fine I can receive data correctly in each side.

But when I send the data from UART to two PRX, the PRX side will not receive the correct data(from PTX) but will receive the data sent by itself.

I find the same question in Sometimes receiving the packages I am sending over ESB. But it didn't reply to fix the problem.

Hope you can give some suggestion.

Best regards,

Lurn

  • Hi,

    But when I send the data from UART to two PRX, the PRX side will not receive the correct data(from PTX) but will receive the data sent by itself.

    I'm not sure If I understand this correctly. Could you explain a bit more what is meant by "receive the data sent by itself" ? 

  • Hi Sigurd,

    The complete process I made is like this.

    When the PTX send data from UART to PRX, at the same time the PRX will send data to PTX(with ACK payload), Under normal circumstances the PRX side will receive data from PTX, but I found that this is not the case here. The PRX side has received the data it sent itself, and the PTX side has received the data too.

    like this  TX send A to RX, at same time RX send B to TX

    The PRX should only receive data A but it also receive data B via ESB. The TX side also received the data A.

    Best regards,

    Lurn

  • Hi,

    I found that this happens only when I go to the UART queue to fetch data. Because I set a queue and push some data in a new thread, it works fine. In this case the UART in PTX side will not send data.

    But when I use the device to sent data to PTX via UART and pop the data from UART queue.Then send it through ESB. the problem arises.

    Is something wrong with UART?

    here is code about uart

    void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
    {
        nrf_libuarte_async_t *p_libuarte = (nrf_libuarte_async_t *)context;
        ret_code_t ret;
    
        switch (p_evt->type)
        {
            case NRF_LIBUARTE_ASYNC_EVT_ERROR:
                PRINTF("NRF_LIBUARTE_ASYNC_EVT_ERROR = %d.", p_evt->data.errorsrc);
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                buffer_t buf = {
                    .p_data = p_evt->data.rxtx.p_data,
                    .length = p_evt->data.rxtx.length,
                };
                ret = nrf_queue_push(&m_buf_queue, &buf);
                APP_ERROR_CHECK(ret);
                nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                break;
            default:
                PRINTF("Unexpected LibUarte Event = %d.", p_evt->type);
                break;
        }
    }
    
    
    static int uart_cmd_set(uint8_t * data, uint8_t len)
    {
        uint8_t ret;
        BaseType_t xReturn = pdTRUE;
        buffer_t buf = {
            .p_data = data,
            .length = len,
        };
        switch(data[2])
        {
            case REAL_TIME_SHARE:
                ret = nrf_queue_push(&real_time_queue, &buf);
                break;
            default:
                break;
        }
        return ret;
    }
    
    void uart_main(void)
    {
        uint8_t err_code;
        while (!nrf_queue_is_empty(&m_buf_queue))
        {
            err_code = nrf_queue_pop(&m_buf_queue, &buf);
            APP_ERROR_CHECK(err_code);
            uart_cmd_set(data_array, index);
        }
    }

    There is also an esb_share() in the previous reply, the esb_share will be call in another thread to send data.

    Note: I use libuarte to transfer data.

    Best regards,

    Lurn

  • Hi,

    I modify the UART IRQ handler to distinguish different packets and put them in different queues. Now this problem doesn't occur again(I just tested it a few times,but it used to happen every time), but I still don't know why.

    At first, I will put all packets to a same queue then in UART_main to distinguish it and use switch...case... to put it in different queues, now I'm just moving the process forward.

  • Hi Sigurd,

    Are you still following this issue?

     I get this problem again. And this problem will only appear when it is transmitted in two -way.

    Can you give me some suggestions?

    Best regards,

    Lurn

Related