MUX to SAR to DMA two arrays | Cypress Semiconductor
MUX to SAR to DMA two arrays
Using the CYC8KIT-050, I am trying to multiplex two analog inputs to a ADC_SAR and have the two channels' input samples go to separate arrays. Disclosure: I have had a case open on this for two weeks but the only response I got was a lame example of a single analog input pin sending 200 samples to Array1 and then 200 samples to Array2 using two TDs. That's not what I need to do. I need one sample from input A, then a sample from input B ... repeat until 2040 samples are collected in each array ( DMA_A and DMA_B ). Later I need to time align the samples in a FIR Filter (not shown in this simplified version). My problem is that I seem to only write to the first element of each array -- at best.
In the TopDesign I am using a LUT to select the MUX input. I'm using a countdown timer to generate an Interrupt when we have 4080 samples collected. Each EOC ticks down the timer and generates a new SOC delayed by 1.5us through the PWM. I'm using two TDs, one for each array.
In the project attached, the DMA_Done ISR serves no purpose. In another version, I sent one sample to a single variable using one TD, then used the ISR to load it into either DMA_A or DMA_B. I checked to see if our sample count was even or odd to determine which array to load like this:
CY_ISR(DMA_Done) // interrupt handler for DMA done
if (adc_count & 1) // See if the array offset is even or odd
DMA_B[adc_count] = adc_read; // it's odd -- Load Right Channel
DMA_A[adc_count] = adc_read; // it's even -- Load Left Channel
adc_count++; // adc_count is declared as volatile
DMA_Done_flag = 1;
In the while (forever) loop, I print the values of DMA_A elements 1,2,and 3 on the top row of the LCD. I print DMA_B elements 1,2,3 on the sencond row. NOTE: To test this you must assure that at least one channel's input connection to the potentiometer on P3 in the cydwr. Note that the dummy initalizations in lines 169,170 do not get overwritten by data as shown on the LCD.
If this method is not feasible, perhaps someone could suggest a C++ structure that could separate every other element from a single array without using CPU cycles in a for loop. The single starting array would be:
But my FIR Filter will have to see:
sampleA,sampleA,sampleA... in channel A, and
sampleB,sampleB,sampleB... in channel B
Workspace Bundle attached. Thank you.