[4M] Memory -> GPIO Port with DMA [Solved]

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.
cadi_1014291
Level 6
Level 6
25 likes received 10 likes received 10 likes given

Hi,

   

I'm doing a silly project where i have an array of random numbers and i would like to transfer each element of the array to the GPIO Port 1 with DMA, each transfer must be done when the user on-board button is pressed.

   

The DMA component is configured to transfer Byte -> Word, incrementing the source one element after each transfer.

   

I thought the following line will make the project run, but it seems like it does not:

   

DMA_Start((void *)array, (void *)Pins_DR);

   

Any thoughts?

   

 

   

I'm mostly new to PSoC 4 DMA so maybe there's a obvious mistake. I'm using the CY8CKIT-043 board.

   

Project is attached. thanks in advance

   

Carlos

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

Two things I see at first glance:

   

    DMA_Start((void *)array, (void *)(&Pins_DR));  // You need the address ao Pins_DR !!

   

and in DMA component you need to specify Number of data elements to transfer as 25 or however the size of your array is.

   

You should additionally think about what to do when all the bytes are transferred.

   

 

   

Bob

0 Likes
lock attach
Attachments are accessible only for community members.
cadi_1014291
Level 6
Level 6
25 likes received 10 likes received 10 likes given

Hi Bob,

   

Yep, i forgot to set the number of data elements to transfer and didn't know i had to place the & operand on the second parameter, already did a project with DMA that seems it's working and i didn't use & on both parameters.

   

Is there a way to specify with the DMA GUI configuration window that i want to do a loop over the td0 when it's completed? I only found a API (x_SetNextDescriptor()), but it seems to do a loop 'by default'.

   

Will read the port with a logic analyzer and see if the array elements are sent correctly.

   

Attached is the project working.

   

Thanks for the help Bob 😄

   

Carlos

   

EDIT

   

The debugger don't seem to refresh automatically every time a register changes, i had to play the program, push the button, pause the program and see how the register changed.

   

Automatic refresh will be fixed, or it's already available?

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Carlos,

   

Attached is example demo of Array - DMA - ControlReg - Pin.

   

   

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

You can set a breakpoint on a register change (you need to dig a bit for its address).

   

An automatic refresh is not possible: the transfer would need the CPU whic of course would disturb the normal program flow.

   

 

   

Bob

0 Likes
cadi_1014291
Level 6
Level 6
25 likes received 10 likes received 10 likes given

Damn, long time, sorry for the late reply, i did not get the notification ;(

   

Thanks odissey, i will check the project right now! i will have to port it to work on PSoC4M tho.

   

Thanks for the help Bob, don't know what this forum would do without your help 🙂

   

 

   

Carlos

0 Likes
lock attach
Attachments are accessible only for community members.
cadi_1014291
Level 6
Level 6
25 likes received 10 likes received 10 likes given

   

So now it kind of works as i want, but i was expecting to transfer just 1 byte from the memory array every time is a rising edge of the Timer_tc (see image), and as you can see the 5 bytes of the array are transferred, then the DMA_Interrupt gets triggered, this is when the data is fully transferred.

   

On the image b0 = 2.0, b1 = 2.1 and so on, my LA is only 8 channels so could not attach more signals (it's midnight and i'm lazy to find the other 2 wires xD).

   

 

   

Any thoughts?

   

Thanks in advance, the current project is attached :), done in Creator 4.0

   

Carlos

   

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Carlos,

   

attached RAM-DMA-Creg project for PSoC4M. Works fine except max clock frequency is less than 1MHz. I can't find the reason.

   

  

   

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Carlos, updates to your project attached (DMA_RAM-GPIO)

   

   

Great illustrator!

0 Likes
lock attach
Attachments are accessible only for community members.
cadi_1014291
Level 6
Level 6
25 likes received 10 likes received 10 likes given

Hi oddisey,

   

Thanks for the help, checking your projects and reading the DMA datasheet i realized the pulse parameter must be set to unknown, this will only trigger the DMA transaction on the rising edge on tr_in input, other parameters will trigger the DMA continually.

   

So i think finally the project is working nicely, below the logic analyzer capture 🙂 (sorry for the letter i was writing with the pc mouse xD)

   

Thanks a lot, the project is attached.

   

Carlos

   

   

0 Likes