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

UART FIFO Flush: How to determine that UART TX is completed

Hi everyone,

in our project we transmit from an android app to Nordic BLE big amount of data (up to 180.000 bytes). I do it by using hvx notifications (MTU 247) and each time I get the notification I try to transmit the data over UART. But we have realized that the uart TX takes too much time and causes packet loss. So I have decieded to store the BLE data and send it after the BLE notifications are completed. Now I face the problem that the UART FIFO (2048) will be full and causes system fault. I need to find out a way where I can determine when the TX transmition is completed and I can flush the TX buffer. I ve searched the uart driver but could find the right function for that. Can anyone help me regarding that?

Thx and Regards

  • Hi 

    If you have room to buffer the entire image in RAM then you should be able to simply use this buffer. Once the BLE data starts coming in you store it in the buffer, and once the buffer has got enough data to send a block over the UART you send a block from the buffer over the UART. 

    The incoming data from BLE will always go to the buffer first, and it doesn't matter what the UART is doing. 

    If the UART is quicker than the BLE link then they will stay more or less in sync, but if the UART is slower then the buffer will store the data while the UART is working. 

    Comodo said:
    Regarding LOG_INFO or debug information; does it has any impact on UART speed? 

    Which backend are you using? 
    The RTT backend should have very little impact on system performance. 

    Best regards
    Torbjørn

  • Hi I have tried that with a buffer of 100.000Bytes size and fed it with BLE data but it is always the same:

    -> NRF_ERROR_NO_MEM (4)

    I have also tried to buffer 20 Packets (20 x 244Bytes) and start then with the UART but no effect.

  • Hi 

    It seems like the buffers are full then. When the NRF_ERROR_NO_MEM error occurs you should stop sending bytes to the UART, and buffer them locally instead. 

    Once the APP_UART_TX_EMPTY event occurs you know that the UART has emptied it's internal buffers and are ready to receive more data. 

    Best regards
    Torbjørn

Related