Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > DMA as Double Buffer (Ping Pong Buffering)

Bookmark and Share
Cypress Developer CommunityTM
Forums | Videos | Blogs | Training | Rewards Program | Community Components



DMA as Double Buffer (Ping Pong Buffering)
Moderator:
ANCY

Post Reply
Follow this topic



DMA as Double Buffer (Ping Pong Buffering)

Diode Dan posted on 05 Feb 2011 6:28 PM PST
Top Contributor
46 Forum Posts

Hello,

I would like to use the DMA as a double buffer between two seperate arrays in memory. The datasheet says this is possible, but does not address how to do so. 

The buffers are in code as follows:

uint8 buf[256]; //Data buffer to hold the output from the 8 bit counter

uint8 buf2[256];//2nd buffer for double buffering 

Any ideas? I am basing my project off of the PSoC Sensei blog FIFO component.

http://www.cypress.com/?rID=46730

 




Re: DMA as Double Buffer (Ping Pong Buffering)

kiku posted on 08 Feb 2011 06:27 PM PST
Cypress Employee
61 Forum Posts

Can you explain me how it should work so that I can write a code snippet and give it to you?


Regards,

Kishore.



Re: DMA as Double Buffer (Ping Pong Buffering)

Diode Dan posted on 09 Feb 2011 08:32 AM PST
Top Contributor
46 Forum Posts

Kishore,

Thanks for the reply.

The idea here is that the DMA component will fill one memory buffer until it is full. Once that 1st buffer is full, the DMA stops filling the first buffer, and starts filling the second buffer. While the 2nd buffer is being filled, the DMA (possibly a second channel) sends the data from the 1st buffer to another location (some kind of communications interface such as USB or UART). After the 1st buffer is done filling, the 2nd buffer is written out to the comm. interface and the 1st buffer is filled.

Here is a quick summary:

State 1) -> 1st buffer NOT full

DMA filling buffer 1

buffer 2 left alone (CPU or another DMA moves/operates on the data)

State 2) -> 1st buffer full

buffer 1 left alone

DMA filling buffer 2

This then continues. I have been using the hardware FIFO component from PSoC Sensei. I hope this clarifies things. I wasn't sure if this would require multiple DMA channels, multiple transaction descriptors, or another mechanism.

Thanks,

DiodeDan

 



Re: DMA as Double Buffer (Ping Pong Buffering)

Diode Dan posted on 15 Feb 2011 11:24 AM PST
Top Contributor
46 Forum Posts

 Update:

I've been playing with this. I started using two TDs with one DMA channel. The TDs write to different buffers in memory. They are linked to each other in a loop.

This appears to be somewhat working.

Is this something that I should open a support case for?

Thanks,

DiodeDan



Re: DMA as Double Buffer (Ping Pong Buffering)

kiku posted on 15 Feb 2011 09:22 PM PST
Cypress Employee
61 Forum Posts

Yes it would be better if you create a Tech Support case for this with the explanation which you gave for Ping-Pong as it would require some time.

 

Regards,

Kishore.



Re: DMA as Double Buffer (Ping Pong Buffering)

Helmut posted on 17 Oct 2012 09:44 AM PST
Top Contributor
48 Forum Posts

See appnote AN52705 page 12 section "Example 5: Ping-Pong Buffer".

app note: www.cypress.com/?docID=38384 

dma webpage including app note link: http://www.cypress.com/?rID=37793



Re: DMA as Double Buffer (Ping Pong Buffering)

Bob Marlowe posted on 17 Oct 2012 11:53 AM PST
Top Contributor
1768 Forum Posts

@Helmut

I fell into a similar trap, that thread you replied to is more than 1 year old. I really would enjoy a newer forum software that helps us contributors a bit (or byte) more.

 

Bob



Re: DMA as Double Buffer (Ping Pong Buffering)

Helmut posted on 17 Oct 2012 03:52 PM PST
Top Contributor
48 Forum Posts

 Bob,

Actually, I didn't fall into a trap.  I knew that post was old.  I just added the appnote reference for anyone else searching for info on double buffering, who found that old [effectively unanswered] post.






ALL CONTENT AND MATERIALS ON THIS SITE ARE PROVIDED "AS IS". CYPRESS SEMICONDUCTOR AND ITS RESPECTIVE SUPPLIERS MAKE NO REPRESENTATIONS ABOUT THE SUITABILITY OF THESE MATERIALS FOR ANY PURPOSE AND DISCLAIM ALL WARRANTIES AND CONDITIONS WITH REGARD TO THESE MATERIALS, INCLUDING BUT NOT LIMITED TO, ALL IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT OF ANY THIRD PARTY INTELLECTUAL PROPERTY RIGHT. NO LICENSE, EITHER EXPRESS OR IMPLIED, BY ESTOPPEL OR OTHERWISE, IS GRANTED BY CYPRESS SEMICONDUCTOR. USE OF THE INFORMATION ON THIS SITE MAY REQUIRE A LICENSE FROM A THIRD PARTY, OR A LICENSE FROM CYPRESS SEMICONDUCTOR.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms and Conditions of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms and Conditions of this site. Cypress Semiconductor and its suppliers reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Spec No: None; Sunset Owner: KXP; Secondary Owner: VWA; Sunset Date: 01/01/20