This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/PROCESSOR-SDK-AM437X: Incomplete DMA transfer termination

Part Number: PROCESSOR-SDK-AM437X

Tool/software: Code Composer Studio

I want to use EDMA to receive data through UART, but I don't know how much data I might receive. Therefore, I consider starting a DMA transmission process, setting a relatively large buffer and corresponding receive count, and checking whether the data is received in the buffer at set intervals . How to terminate an incomplete DMA transfer? How to know if and how much data has been received?

  • HI zhuangbin,

    How are you programming the UART & DMA? Are you using PRSDK? Are you programming using the UART LLD or the CSL?

    Regards,
    Frank

  • Hi Frank,

    nice to meet you.

    I am using the pdk :processor_sdk_rtos_am437x_4_03_00_05, Code Composer Studio Version: 7.4.0.00015.

    I am testing the drv on TI-RTOS(bios_6_52_00_12), example UART_BasicExample_dma_evmAM437x_armTestProject, which use the API :UART_open, UART_read, UART_read2, UART_write, UART_write2, and so on. and I found that if I use the UART_readCancel function to cancel  a  UART_read2() with the DMA enable, the number of received characters  is 0 in the call back function; if the EMA disable, we can get the received characters. 

    also, I am testing the example :C:\ti\pdk_am437x_1_0_10\packages\ti\starterware\examples\uart\echo\echo_app_main.c. but I'm worried about whether it is safe to use interrupt directly under tirtos?

  • Hi zhuangbin,

    Sorry for the delayed response.

    The approach to this use case isn't clear to me for the UART LLD. I've reached out internally to the UART LLD developer for help.

    Would it be possible for you to implement a transmission protocol over UART? The "payload" of a first packet of known length would contain the length of a subsequent packet. The UART LLD read API function could then be called with the received length. This would avoid the problem of known or variable Rx transmission size.

    >> safe to use interrupt directly under tirtos

    It should be safe, provided you handle it properly. Please search for "Osal_RegisterInterrupt()" in the pdk folder.

    Regards,
    Frank

  • zhuangbin,

    I spoke with the UART LLD developer about this. The UART LLD would need to be modified to support the use case of indeterminate number of Rx characters. A basic outline follows:

    Enable two interrupts / callbacks:

    1. DMA – fires when DMA completes transfer. DMA transfer initiated when Rx data above threshold, DMA transfers “threshold” worth of chars from Rx FIFO.
    2. RHR/CTI (a combined interrupt for the UART hardware) – fires when Rx FIFO above threshold or time out occurs. Interrupt type determined in ISR. ISR “skips” RHR interrupt. ISR handles time out case by transferring remaining bytes in Rx FIFO since DMA won’t transfer these bytes.

    If possible, I'd recommend using a Rx-Tx protocol to circumvent this issue.

    Regards,
    Frank

  • Hi Frank,

    I understand what you mean.  I will have to chang the driver code. 

    Thank you very much.