uint16 [1024] ADC window buffer using DMA

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

cross mob
sccac_1236541
Level 4
Level 4

Hi all,

   

I would like to create a static adc window that specifically buffers 1024 2byte-words but does not slide.

   

I am thinking DMA would be the most efficient way to do this.  I would have to use multiple TD's I'm assuming since the ADC_sample() only gets one 16 bit sample at a time but I need to create an array of them, but since the number of TD descriptors is limited to 128 I would have to use two sets of DMAs with a counter to determine when the one dma has fully buffered 128 2byte-words and then transfer those 128 2byte-words to a different buffer, essentially doing the second transfer 8 times.  Of course I wil have to use a counter to determine when the first DMA buffer is finished to make sure I don't grab overlapping data.  Once all of this is done I can have another counter looking at the second dma to determine when it has completed 8 transfers. 

   

 

   

Is this something that is achievable using the PSoC 5lp? 

   

If there is a better way please let me know, or if I am thinking about this wrong.

   

 

   

Thanks,

   

scarlson

0 Likes
5 Replies
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Some dma ap notes (ther eis a 16 bit example in one of them if I am not mistaken, AN61102 ?) -

   

 

   

http://www.cypress.com/documentation/application-notes/an52705-psoc-3-and-psoc-5lp-getting-started-d...                                             AN52705     Getting Started with DMA

   

http://www.cypress.com/documentation/application-notes/an84810-psoc-3-and-psoc-5lp-advanced-dma-topi...                          AN84810     PSoC® 3 and PSoC 5LP Advanced DMA Topics

   

http://www.cypress.com/documentation/application-notes/an61102-psoc-3-and-psoc-5lp-adc-data-bufferin...                AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA

   

http://video.cypress.com/video-library/search/dma/     Videos on DMA

   

https://www.youtube.com/results?search_query=dma+psoc Videos on DMA (some overlap)

   

 

   

Regards, Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

DMA is complicated, but not as complicated as you think. Since you can use a single TD in a loop you will not need more than one TD to get your 1024 words into memory, two  TDs when you want to use double buffering and additional two TDs when grabbing the buffers and moving them to another location. No counting on your side is needed, that is performed by the DMA channels from which you will need two, one for each transfer.

   

 

   

Bob

0 Likes
sccac_1236541
Level 4
Level 4

So if I hear you right even though the adc_getsample16() only returns one sample everytime the eoc is flagged I can use one TD to pass that data to a buffer, and on the next eoc flag it will grab the new sample and place it in sequentially in the buffer right after the first sample until it has done that for 1024 samples, and then start to repeat that same process?

   

I must have read the ANs wrong, I did not think that was possible to use the same TD without overwriting the same destination address each time.

   

 

   

Also thanks danaaknight, I saw those ANs but not the videos.  I will take a look.  it seems like the example may be what I am trying to do actually.

   

 

   

Thanks,

   

scarlson

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Hope the info helps.

   

 

   

Dana.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, quite right. You may specify to increase the destination address by the number of bytes a TD transfers. You may specify that for the source address as well, but in your case -since you get your data from a peripheral- that would not make sense.

   

Have a look at the specifications you can make when using the DMA-wizard from Creator's Tools-menu.

   

 

   

Bob

0 Likes