Libuarte+app template ERROR 0 [NRF_SUCCESS]

Hi,
I have added libuarte example in-app template and sent data from Arduino to nRF52840 successfully. But after receiving some data and I am getting the following error. Any solution please?
Thanks!




Parents
  • Hi,

    Have you remembered to free the RX buffer in the uart event handler? Could you show me how the handler has been implemented? 

    regards

    Jared 

  • Thanks for the reply. Here is the function

    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:
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
    
                if((unsigned char)*(p_evt->data.rxtx.p_data)!=0)
                {
                      received_data[count_data]=(unsigned char)*(p_evt->data.rxtx.p_data);
                      count_data=count_data+1;
                      if((unsigned char)*(p_evt->data.rxtx.p_data)==35)
                          data_completed=true;
                }
    
                m_loopback_phase = true;
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                if (m_loopback_phase)
                {
                    nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
                    if (!nrf_queue_is_empty(&m_buf_queue))
                    {
                        buffer_t buf;
                        ret = nrf_queue_pop(&m_buf_queue, &buf);
                        APP_ERROR_CHECK(ret);
                        UNUSED_RETURN_VALUE(nrf_libuarte_async_tx(p_libuarte, buf.p_data, buf.length));
                    }
                }
    
                printf("Tx Called\n");
    
                break;
            default:
                break;
        }
    }
    
    
    //UART
    
    


Reply
  • Thanks for the reply. Here is the function

    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:
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
    
                if((unsigned char)*(p_evt->data.rxtx.p_data)!=0)
                {
                      received_data[count_data]=(unsigned char)*(p_evt->data.rxtx.p_data);
                      count_data=count_data+1;
                      if((unsigned char)*(p_evt->data.rxtx.p_data)==35)
                          data_completed=true;
                }
    
                m_loopback_phase = true;
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                if (m_loopback_phase)
                {
                    nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data, p_evt->data.rxtx.length);
                    if (!nrf_queue_is_empty(&m_buf_queue))
                    {
                        buffer_t buf;
                        ret = nrf_queue_pop(&m_buf_queue, &buf);
                        APP_ERROR_CHECK(ret);
                        UNUSED_RETURN_VALUE(nrf_libuarte_async_tx(p_libuarte, buf.p_data, buf.length));
                    }
                }
    
                printf("Tx Called\n");
    
                break;
            default:
                break;
        }
    }
    
    
    //UART
    
    


Children
Related