You are here

Accessing variable starting points in an array with DMA | Cypress Semiconductor

Accessing variable starting points in an array with DMA

Summary: 1 Reply, Latest post by 78RPM on 31 Oct 2015 10:27 AM PDT
Verified Answers: 1
Last post
Log in to post new comments.
Jack Vaughan's picture
1 post

Hello my PSoC heros!

Theoretical setup:

A series of 11 arrays with 4000 bytes each filled by  DMA_1 with chained TDs as a circular buffer of 8bit audio samples from an ADC_DelSig (44ksps). 

uint8 adc_bufferArray1[4000]={0};
uint8 adc_bufferArray11[4000]={0};

DMA_2 is configured as a chain of TDs (advanced by the same ADC_DelSig EOC) to transfer a new byte from the circular buffer to a VDAC but with an offset starting point to cause a delayed output.

The goal is to control this offset with a variable to change the delay time. 

I've almost wrapped my head around how to change DMA_2's starting TD with a variable giving 10 or 11 different delay times. In the meantime priority is given to DMA_1 to avoid conflicts, although I think there's a way to track this with a counter/status register or something.

My question: is there a way, using DMA, to vary the starting TD and the byte in that particular source with a variable?

(I have the variable obtained and scaled via SAR_ADC and a potentiometer.)

Thank you in advance for any wisdom you may offer and the time to articulate it!!! I've been reading your posts for months and really appreciate your guidance and ideas.



user_302397898's picture
102 posts

I don't think you can change the order of the TDs dynamically but you can change the pointer into your Array. Rather than have the TD point to a specific Array or Array element, have its output directed to a pointer pA[0] or elsewhere. You can change the pointer prior to each call of the TDs.

for example:
#define LENGTH 4000
#define NUM_TDs 11
uint16 *pA[NUM_TDs]; // an array of pointers

void set_pointers()  // Sets the pointers to the output arrays
    uint16 j;
    for (j = 0; j < NUM_TDs; j++)
        pA[j] = &(adc_bufferArray[some offset value here wherever you want to point]);

Then let your TD use these pointers:

CyDmaTdSetAddress(adc_bufferArray[0], LO16((uint32)&sar_finalArray[0]), LO16((uint32) pA[0]));

Log in to post new comments.