Correct way to determine current TD of a DMA

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
josc_1234441
Level 1
Level 1
First like received

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

   

0 Likes
1 Solution
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Probably, the order should be the opposite; when ISR fired, the currentTD will mark the next TD already

  1.   if (currentTD == DMA_1_TD[0]) 
  2.            //process dest buf 1... 
  3.   else if (currentTD == DMA_1_TD[1]) 
  4.            //process dest buf 0

View solution in original post

2 Replies
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Probably, the order should be the opposite; when ISR fired, the currentTD will mark the next TD already

  1.   if (currentTD == DMA_1_TD[0]) 
  2.            //process dest buf 1... 
  3.   else if (currentTD == DMA_1_TD[1]) 
  4.            //process dest buf 0
Vison_Zhang
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 250 sign-ins

Post1 is correct i think.

0 Likes