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

nRF52832 reinitialize the UART

Hello.

I am working on ble project and using uart communication between bluetooth and stm32. I need to reinitialize uart module in case of any error in event handler but I don't know how to do.  I found an example that was used serial_dfu_transport_init and serial_dfu_transport_close functions. Is it a good idea using dfu transport? Is there any solution or example for my problem? Thanks.

Parents
  • Hi 

    Which UART driver are you using?

    It shouldn't be necessary to re-initialize the UART in the cause of a UART error, it is just meant as a notification to the application that there might be issues on the UART bus. 

    Using the serial_dfu_transport library in place of one of the regular UART drivers is not recommended, unless you want to use DFU over UART. 

    Best regards
    Torbjørn

  • I am using UART0 and i don't use dfu. I wrote the code below.

    if (p_event->type == NRF_DRV_UART_EVT_ERROR) {
    /* Clear all events. */
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_TXDRDY);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_RXDRDY);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_RXTO);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_ERROR);
    /* Uninitialize the UART driver. */
    nrf_drv_uart_uninit(&uart);
    /* Initialize the UART. */
    uart_init();
    }

Reply
  • I am using UART0 and i don't use dfu. I wrote the code below.

    if (p_event->type == NRF_DRV_UART_EVT_ERROR) {
    /* Clear all events. */
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_TXDRDY);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_RXDRDY);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_RXTO);
    nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_ERROR);
    /* Uninitialize the UART driver. */
    nrf_drv_uart_uninit(&uart);
    /* Initialize the UART. */
    uart_init();
    }

Children
Related