2 Replies Latest reply on Apr 1, 2019 6:24 PM by XiaoweiZ_71

    Correct way to determine current TD of a DMA

    josc_1234441

      I have a single DMA channel that has two TDs. The configuration is as follows.

      The DMA interrupt gets called each time one of the TDs is finished. In the ISR, I want to know how to determine which buffer was last filled and should be processed.

       

      I have attempted the following but not sure if it is correct.

       

      CyDmaTdSetConfiguration(DMA_1_TD[0], TFR_CNT, DMA_1_TD[1], ...
      CyDmaTdSetConfiguration(DMA_1_TD[1], TFR_CNT, DMA_1_TD[0], ...
        
      CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32)ADC_SAR_1_SAR_WRK0_PTR), LO16((uint32)&dest_buf0[0]));
      CyDmaTdSetAddress(DMA_1_TD[1], LO16((uint32)ADC_SAR_1_SAR_WRK0_PTR), LO16((uint32)&dest_buf1[0]));
      
      
      CY_ISR(ISR_DMA_DONE_ADC)
      {
        CyDmaChStatus(DMA_1_Chan, &currentTD, NULL);
      
        if (currentTD == DMA_1_TD[0])
      //process dest buf 0...
        else if (currentTD == DMA_1_TD[1])
      //process dest buf 1