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

LIBUARTE on ble_app_uart with DMA

Hi All,

I have 2 boards nrf52840 pc10056 and I need to run ble_app_uart using LIBUARTE with DMA in order to obtain a more robust uart communication

I would like to use an uart DMA that will work in background saving the byte received in a buffer (fixed length) and once that it is full having an interrupt where I can check this buffer and send it to the central unit.

Is there any easy way to set  everything up and change the code of ble_app_uart? Any suggestion??

Thanks

Parents
  • Hi

    Thank you for the clarification! Is by any chance the TX buffer not cleared after sending a message, and that is what is causing this error? If not, are you able to get an error code so we can see where exactly this error originates?

    Best regards,

    Simon

  • Hi,

    I do not use any TX buffer (not that I know). Because in this case I'm not writing on the UART, I'm just reading, sending to the central and make free the RX buffer. 

    I cannot get an error code. In the code that I put back here, there is APP_ERROR_CHECK(err_code), but the program does not go there.

    void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
    {
        nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
        uint32_t       err_code;
        ret_code_t ret;
    
        switch (p_evt->type)
        {
            case NRF_LIBUARTE_ASYNC_EVT_ERROR:
                bsp_board_led_invert(1);
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                bsp_board_led_invert(2);
                err_code= ble_nus_data_send(&m_nus, p_evt->data.rxtx.p_data, &p_evt->data.rxtx.length, m_conn_handle);
                do
                {
                    if ((err_code != NRF_ERROR_INVALID_STATE) &&
                        (err_code != NRF_ERROR_RESOURCES) &&
                        (err_code != NRF_ERROR_NOT_FOUND))
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                } while (err_code == NRF_ERROR_RESOURCES);
                nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data , p_evt->data.rxtx.length);    // if I remove this line of code I will have more or less the same behavior 
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                bsp_board_led_invert(3);
                break;
            default:
                break;
        }
    }

Reply
  • Hi,

    I do not use any TX buffer (not that I know). Because in this case I'm not writing on the UART, I'm just reading, sending to the central and make free the RX buffer. 

    I cannot get an error code. In the code that I put back here, there is APP_ERROR_CHECK(err_code), but the program does not go there.

    void uart_event_handler(void * context, nrf_libuarte_async_evt_t * p_evt)
    {
        nrf_libuarte_async_t * p_libuarte = (nrf_libuarte_async_t *)context;
        uint32_t       err_code;
        ret_code_t ret;
    
        switch (p_evt->type)
        {
            case NRF_LIBUARTE_ASYNC_EVT_ERROR:
                bsp_board_led_invert(1);
                break;
            case NRF_LIBUARTE_ASYNC_EVT_RX_DATA:
                bsp_board_led_invert(2);
                err_code= ble_nus_data_send(&m_nus, p_evt->data.rxtx.p_data, &p_evt->data.rxtx.length, m_conn_handle);
                do
                {
                    if ((err_code != NRF_ERROR_INVALID_STATE) &&
                        (err_code != NRF_ERROR_RESOURCES) &&
                        (err_code != NRF_ERROR_NOT_FOUND))
                    {
                        APP_ERROR_CHECK(err_code);
                    }
                } while (err_code == NRF_ERROR_RESOURCES);
                nrf_libuarte_async_rx_free(p_libuarte, p_evt->data.rxtx.p_data , p_evt->data.rxtx.length);    // if I remove this line of code I will have more or less the same behavior 
                break;
            case NRF_LIBUARTE_ASYNC_EVT_TX_DONE:
                bsp_board_led_invert(3);
                break;
            default:
                break;
        }
    }

Children
No Data
Related