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.

TMS570LS3137: Check for DMA transfer completed

Part Number: TMS570LS3137

Tool/software:

Hello,

I am trying to use DMA for the received data on the SPI peripheral (standard SPI, not the MibSPI). It seems to mostly work fine, but when having multiple successive transfers I noted that the last frame of the block is instead transferred to the next destination. I've set up a small example project and you can see in the screenshot below that the 4th element of the src array was sent to dest2 array instead of dest array.

I assume it is because I start the next transfer before the previous one fully completed (if I add some delay in between it works fine, see the dest3). I tried reading different bits of the DMA status registers (GCTRL, DMASTAT, PEND, PTCRL) to get confirmation that the DMA transfer completed, but none of them work. Is there a more reliable way to achieve this?

For reference, my example code is available here:

test_spi_dma.zip

Thank you and best regards,

Aaron

  • Hi Aaron,

    You are correct about the issue; you should need to wait till the transfer complete before initiating next transfer.

    I am attaching reference code for you with the modifications:

    7360.test_spi_dma.zip

    Here is the result after modifications:

    --
    Thanks & regards,
    Jagadish.

  • Hello Jagadish,

    Thank you for the sample code, I tested and it now indeed works as expected. I am surprised because I actually also previously tried to read the BTC flag to check of the confirmation of the block transfer end, but I must have done it wrong.

    Thank you and best regards,

    Aaron

    EDIT:
    Note for other readers in the future that can't access the sample code, this is the correct way to wait for the end of the DMA block transfer:

    while(!(dmaREG->BTCFLAG & (1 << DMA_CH0))); /*Wait Until the block transfer completed*/
    dmaREG->BTCFLAG |= (1 << DMA_CH0);          /*Clear BTC*/

  • Note for other readers in the future that can't access the sample code, this is the correct way to wait for the end of the DMA block transfer:

    Thanks, Aaron, for this!