Sequencing SAR ADC with greater than 2 channels and DMA

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

cross mob
lock attach
Attachments are accessible only for community members.
StFa_285751
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

 Hi folks,

   

I'm looking to DMA from the Sequencing SAR ADC to a results array. I have no problem with 2 channels, but once I go to more than 2 channels I only get the first 2 channel results repeated. I've gone over and over the DMA setup and I think it is correct but I must be missing something. I used this article www.cypress.com/ as a base to get the 2 channel setup working.

   

I've written a minimum project (attached) that in my mind should work when the number of channels in the designer is changed. There are 2 results arrays; 1 which extracts the results from the ADC using the API GetResult16() function, and 1 which gets the results via DMA. If you put a breakpoint on the "DMADone = 0;" line in main.c you can compare the results in the two arrays. These are equivalent when sampling two channels...but any channels over that don't appear in the results. (I've set up a few different voltages on the input pins to test it).

   

From reading the documentation I understand that the number of bytes in each DMA burst should be NumChannels * sizeof(uint16) to read all the results from the ADC_1_finalArray, and the TD should be set to be the number of results array elements * sizeof(uint16).

   

I have the TD set such that the destination results array increments automatically, which from the DMA documentation I think should take the size of the number of bytes per burst into account. I wonder however, if this is incrementing correctly for two input channels but needs some adjustment for more channels than that.

   

Any info and help would be much appreciated.

   

Regards,
Stephen

0 Likes
40 Replies
StFa_285751
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

 Hi Jerry,

   

Yes, AN61102 does specifically address the crux of the issue, transferring data wider than the spoke width while resetting the source address. And the final design I came up with is analogous to the solution given in that AN. I was sure I could manage the same result with a single DMA channel and indexed DMA, but I coudn't get it to work in the end. I'd still love to see a working example of indexed DMA on a PSoC5LP so I could find out why I couldn't get it to work, because I have some ideas as to how I could use it for other purposes (taking over the world, etc.).

   

Happily I am know much more comfortable with DMA in general than I was when I started; a good learning experience.

   

Thanks all.

   

Stephen

0 Likes