Cypress Perform

Home > Design Support > Cypress Developer CommunityTM > Cypress Forums > PSoC® 5 > Read counter register using DMA

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



Read counter register using DMA
Moderator:
ANCY

Post Reply
Follow this topic



Read counter register using DMA

pavloven posted on 02 Aug 2012 1:03 PM PST
Top Contributor
78 Forum Posts

Please, tell me, how to solve the problem:
I wanted to create a component which only uses DMA (without the program).

I read counter register and record it in the  register of timer.
BUT!    I shall be obliged in the program perform such an operation:
counter_status = Multi_Pulse_1_Counter_ReadStatusRegister ();

Question:     how not to do it.

The project is attached below.




Re: Read counter register using DMA

Bob Marlowe posted on 02 Aug 2012 01:36 PM PST
Top Contributor
1768 Forum Posts

That should work with capturing. Every captured value goes into the FIFO from which DMA reads.

So without CPU intervention you'll need a signal that captures the data which in turn will generate an interrupt on capture which starts a DMA request.

 

Bob



Re: Read counter register using DMA

pavloven posted on 03 Aug 2012 11:15 PM PST
Top Contributor
78 Forum Posts

Thanks Bob, but I yet didn't understand.  This project works.

To me it is not clear: why capture register ('$INSTANCE_NAME' _Counter_STATICCOUNT_LSB_PTR for DMA) are updated only after Counter_ReadStatusRegister () will be executed.

 



Re: Read counter register using DMA

Bob Marlowe posted on 03 Aug 2012 12:59 PM PST
Top Contributor
1768 Forum Posts

You were talking about a timer, not a PWM and you were asking for something that would work without CPU-usage.

So I thought you were asking for an extension to your project. The FIFO is acted on a capture in a timer module or by software but I think there was something mentioned in the datasheet not to use a counter_Read() when using DMA.

So, what exactly do you want to perform/improve?

 

Bob



Re: Read counter register using DMA

pavloven posted on 03 Aug 2012 02:21 PM PST
Top Contributor
78 Forum Posts

I'm trying to create by the hardware component which only uses DMA (no ISR no program)
I was not able to achieve this goal:
Line 40 is not sending data until the Counter Status Register will not be read by software:
Multi_Pulse.c
. . . . . . . . . . . . . . .
40    CyDmaTdSetAddress(   `$INSTANCE_NAME`_DMA_TD[0],     LO16((uint32)`$INSTANCE_NAME`_Counter_STATICCOUNT_LSB_PTR),      LO16((uint32)`$INSTANCE_NAME`_Timer_1_PERIOD_LSB_PTR));
. . . . . . . . . . . . . . .
I was compelled to create for (;;) in main.c
containing:    counter_status = Multi_Pulse_1_Counter_ReadStatusRegister();
My question is:  how to make the DMA sends the data without using the programm appeal to the Counter Status Register  (with empty   for (;;)  ).

 



Re: Read counter register using DMA

pavloven posted on 04 Aug 2012 12:36 AM PST
Top Contributor
78 Forum Posts

I brushed my project. Now it doesn't work :).
Is it possible to make it work, without the participation of the CPU.



Re: Read counter register using DMA

Bob Marlowe posted on 04 Aug 2012 01:27 AM PST
Top Contributor
1768 Forum Posts

I do not have the time to test, but try

use a second TD which is executed automatically (Auto Next) after the first, transfering 1 byte source is

to a memory location. This should clear the Interrupt bit.

Counter_STATUS_PTR



Re: Read counter register using DMA

Bob Marlowe posted on 04 Aug 2012 01:30 AM PST
Top Contributor
1768 Forum Posts

The forum software mangled the lines of the post. Source is Counter_STATUS_PTR

That's the (pointer to the) register you read to clear the interrupt.

 

Bob



Re: Read counter register using DMA

pavloven posted on 04 Aug 2012 01:58 AM PST
Top Contributor
78 Forum Posts

Thank You Bob. I think I did it. I'll check again.



Re: Read counter register using DMA

pavloven posted on 04 Aug 2012 03:39 AM PST
Top Contributor
78 Forum Posts

I did this:
uint8 DMA_1_Chan;
uint8 DMA_1_TD[1];
uint8 counter_REG = 0;
DMA_1_Chan = DMA_1_DmaInitialize (1, 0,  HI16(CYDEV_PERIPH_BASE), HI16(counter_REG));
DMA_1_TD[0] = CyDmaTdAllocate();
CyDmaTdSetConfiguration(DMA_1_TD[0], 1, DMA_1_TD[0], TD_AUTO_EXEC_NEXT);
CyDmaTdSetAddress(DMA_1_TD[0], LO16((uint32) Counter_STATUS_PTR), LO16((uint32)counter_REG));
CyDmaChSetInitialTd(DMA_1_Chan, DMA_1_TD[0]);
CyDmaChEnable(DMA_1_Chan, 1);

Unfortunately it does not work
 



Re: Read counter register using DMA

pavloven posted on 04 Aug 2012 05:08 AM PST
Top Contributor
78 Forum Posts

Problem solved:

I disabled all of interruption of the timer
Left only Advanced -- > Reload Counter = On Capture
Configure - > Compare Value =0
Thanks for the tip about the interruption.



Re: Read counter register using DMA

Bob Marlowe posted on 04 Aug 2012 09:03 AM PST
Top Contributor
1768 Forum Posts

Congratulations!

And thank you to share your experiences and the code with us.

 

Bob

 






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: GRAA; Secondary Owner: RAIK; Sunset Date: 01/01/20