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

Uarte and ble

According to the description of S132_SDS_v5.0 on page 82, when the establishment of connection, in accordance with the BLE protocol, softdevice will be interrupted frequent send connection event, to ensure that the connection is not broken. (Each tisr (0) is greater than 10us)

In other words, if this time uart baud rate is 1M (each byte takes about 10us), which is what I need, it will lead to the loss of data, and this situation, I have two solutions:

1, DMA buffer to receive, to avoid softdevice timing-critical occupation of cpu lead to loss of bytes

2, hardware flow control, is it will make the RTS pin frequently switch level?

3, the above two cases at the same time use

Is there any other choice?

  • Hi,

    The UARTE peripheral will use EasyDMA for directly accessing RAM buffer. You can also use legacy UART peripheral on nRF52832, without EasyDMA. When using together with softdevice, I would highly recommend that you use the EasyDMA feature to avoid data loss. HWFC should also be used with such high baud rate to avoid overflow.

    Best regards,

    Jørgen

  • Thanks.

    Maybe I understand it wrong.

    In ble_app_uart, UART_RX_BUF_SIZE does not seem to work? Because it is in the interrupt (whether it is ENDRX or RXTO) just received the byte processing, and will not buffer more than 1 byte?

    Other problems, in the uart_event_handler function in app_uart_fifo.c, if the flow control event is generated and still received 4 bytes after RTS is pulled down, because FIFO_LENGTH (m_rx_fifo) <= m_rx_fifo.buf_size_mask is absolute, Implementation of nrf_drv_uart_rx (&app_uar_inst, rx_buffer, 1), then this time is not it will produce BUG? Because there are four bytes inside the RX FIFO? Here read only one.

  • UART_RX_BUF_SIZE is not related to the UART peripheral buffer, but is used to control the size of the RX FIFO buffer used by app_uart library. The library will push/get bytes to/from the FIFOs when needed. The FIFOs will be transmitted/filled by the UART peripheral "in the background".

    As described in the UARTE peripheral documentation, you are able to receive up to 4 bytes after STOPRX task:

    The UARTE is able to receive up to four bytes after the STOPRX task has been triggered as long as these are sent in succession immediately after the RTS signal is deactivated. This is possible because after the RTS is deactivated the UARTE is able to receive bytes for an extended period equal to the time it takes to send 4 bytes on the configured baud rate.

  • Thanks.

    When a uarte receives data

    UARTE0_UART0_IRQHandler> uarte_irq_handler> app_fifo_put> uart_event_handle> app_fifo_get> dealing 1 byte.

    then

    return uart_event_handle> return uarte_irq_handle> return UARTE0_UART0_IRQHandler.

    All of these are done in an interrupt, so I do not know what the difference between UART_RX_BUF_SIZE set to 1 and set to 256?

  • The difference between setting UART_RX_BUF_SIZE to 1 and 256, is that if you set it to 1, you can only receive 1 byte before the FIFO is full. If an external device transmitts more data before you call app_uart_get, there will be no more room in the FIFO buffer to store this data, meaning the external device will have to wait for you to process the data, or the data will be lost. If the buffer size is set to 256, the FIFO buffer can hold 256 bytes before you have to process the data using app_uart_get.

Related