FREERTOS UART DMA CONFIGURE



  • I wish to receive data with undifined length through uart at baud rate 921600 continuously, how should i configure the dma to receive the data?



  • @aaassszzz91

    I've tested the example with baudrate set to 926600, 1000000, 2000000 and 4000000 and it works without issues (tested with minicom).
    The acctual baudrate is slightly different than requested, but it is well within the uart tolerance .

    === RingBuffer UART example ==
    Uart initialized, real baud rate=924170
    M (105338) [UART]: UART task started
    Waiting for data (1st phase)
    [UART_CB]: [9] Pattern received at position 6 (123456)
    [UART_CB]: Requested number of bytes (10) received [1234567890]
    [UART_CB]: [8] Pattern received at position 3 (abc)
    [UART_CB]: [7] Pattern received at position 4 (hhhh)
    [UART_CB]: [6] Pattern received at position 4 (kkkk)
    [UART_CB]: [5] Pattern received at position 3 (ttt)
    [UART_CB]: Requested number of bytes (10) received [Kendrytexy]
    [UART_CB]: [4] Pattern received at position 3 (zaa)
    [UART_CB]: [3] Pattern received at position 4 (K210)
    [UART_CB]: Requested number of bytes (10) received [12345678xy]
    [UART_CB]: Requested number of bytes (10) received [1234567xyz]
    [UART_CB]: [2] Pattern received at position 6 (123456)
    [UART_CB]: [1] Pattern received at position 3 (sss)
    [UART_CB]: [0] Pattern received at position 3 (ZZZ)
    Waiting for 'ABC' sequence
    Received:
    Kendryte K210ABC
    Received:
    1234567890abcdefghijklmnopqrstuvxyzABC
    Received:
    1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 ABC
    Received:
    1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 1234567890abcdefghijklmnopqrstuvxyzACBDEFGHIJKLMNOPQRSTUVXYZ_123456789012345678901234567890 ABC
    

    After the 1st phase is finished, you can send as many characters as you want.
    I've tested by pasting into minicom a string of 1847 characters with ABC pattern in the middle and at the end and it was received as two sequences without erros at all tested baudrates.

    If your data has any kind of delimiting pattern or if you want to receive fixed number of bytes, it is best to use the callback function to get the data for processing.
    If you want to manually query for data in a while loop, it is best to use the uart semaphore, it is fired on every new byte received and ensures the fastest response without using much processor resources.
    Both approaches are ilustrated in the example.

    If you need any other information or assistance it is best to use the GitHub issue tracking.
    I'm usually to bussy with my official work and other tasks for any other kind of communication, sorry.



  • @loboris Hi,may i add you on qq or wechat? i cannot receive full data under baud rate 921600 using while loop to receive uart data or irq, this have troubled me for a long time. please add 909460224, many thanks!



  • @aaassszzz91

    Sorry, the directory was ignored when pushing the commit.
    It it there now.



  • Hi,i went to K210_FreeRTOS_SDK/src/ , there are hello word, kflash.py, MPyTerm.py but no Uart example.



  • @aaassszzz91 said in FREERTOS UART DMA CONFIGURE:

    I wish to receive data with undifined length through uart at baud rate 921600 continuously, how should i configure the dma to receive the data?

    You can find the full example of buffered UART driver in my modified FreeRTOS SDK (src/uart_example).
    Many features and configuration options, full ring buffer implementation, callbacks on number of bytes received and received pattern and many more...