You are here

DMA to Control Register Question | Cypress Semiconductor

DMA to Control Register Question

Summary: 2 Replies, Latest post by Bob Marlowe on 04 Aug 2015 07:35 AM PDT
Verified Answers: 0
Last post
Log in to post new comments.
G's picture
1 post


I have a quick question on DMA to Control Register setup. I've gone through the "Getting Started with DMA" guide, and there is certainly a lot to take in.

What I'm trying to do, mostly for the sake of understanding DMA usage within PSoC 3, is use a pushbutton which requests a DMA update from SRAM (let's assume there's "myVar", a uint8 variable which holds the data) to the value of an 8 bit control register. That is, "myVar"'s value is written via DMA to a control register upon a button press.

Based on my reading of the documents, I feel (and please correct me if I'm wrong) this can be accomplished by using a level (or edge) sensitive 'drq'. But I'm a little stuck on how to proceed from here (or maybe it's the lack of coffee) in code.

You guys at Cypress have, in my opinion, great reference documents for this platform (though I usually find that the most useful ones are the hardest to find!), and I am wondering if anyone can provide some guidance/point me to an app note that addresses my simple use case. Most of the examples seem to use arrays and multi-byte bursts. 

I've included some relevant DMA code, which does not update the control register in hardware, and if anyone's up to the challenge of looking it over for blatant errors, your feedback would be much appreciated.

Thanks, and looking forward to figuring out how to harness the true power of this platform,

Some snippets of attempted code:

//Globally declared
 uint8 myVar = 0u;

 #define do_dma_BYTES_PER_BURST 1
 #define do_dma_REQUEST_PER_BURST 1
 #define do_dma_SRC_BASE (CYDEV_SRAM_BASE)
 #define do_dma_DST_BASE (CYDEV_PERIPH_BASE)

//Snippets pulled from int main()
 do_dma_Chan = do_dma_DmaInitialize(do_dma_BYTES_PER_BURST, do_dma_REQUEST_PER_BURST,
    HI16(do_dma_SRC_BASE), HI16(do_dma_DST_BASE));
 do_dma_TD[0] = CyDmaTdAllocate();
 CyDmaTdSetConfiguration(do_dma_TD[0], 1, CY_DMA_DISABLE_TD, 0);
 CyDmaTdSetAddress(do_dma_TD[0], LO16((uint32)&myVar), LO16((uint32)Control_Reg_1_Control_PTR));
 CyDmaChSetInitialTd(do_dma_Chan, do_dma_TD[0]);
 CyDmaChEnable(do_dma_Chan, 1);

user_14586677's picture
7646 posts

First consideration is button debounced ? If not you could get some strange

behavior. Also generally speaking ISR should occur once for a button press,

so it should be bounced in > bounced out > DMA trigger. Edge triggered.


You might consider posting project so all settings/configs can be looked at.


Some useful docs -                                             AN52705     Getting Started with DMA                          AN84810     PSoC® 3 and PSoC 5LP Advanced DMA Topics                AN61102 PSoC® 3 and PSoC 5LP - ADC Data Buffering Using DMA     Videos on DMA Videos on DMA (some overlap)


Regards, Dana.

user_1377889's picture
9249 posts

Welcome in the forum, G.

Your question why most of the examples are working with arrays is quite easily answered: The setup for "just" a single byte transfer is a large overhead, so a simple assignment would beat the DMA, even an interrupt driven solution would be faster.

It is always advisable to post a workspace bundle so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.




Log in to post new comments.