cannot run DMA2 after 52 times

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.
Anonymous
Not applicable

Hello, 
I have a problem of DMA function on PSoC 5LP(CY8CKIT-050).
I'm trying to sample 2ch many a time using 2 SAR-ADCs and 2 DMAs.
But, 2nd DMA does not run after 52 times.

   

The solution seems to be the configuration of DMAs moved to out of loop and using only "CyDmaChEnable" in loop.
But I could not find this reason. 

   

The Attach is showing values of 52nd and 53rd. They will be same.

   

Thanks,
dzone.

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

Welcome in the forum, dzone!

   

Two things I can see.

   

1st: You call frequently DMA_Config() which allocates resources (DMA channels, TDs) but you never free those. When you declare the Channel and the TD as global, you might re-use them instead of freeing and re-allocate.

   

2nd: You did not get the error yet, but when you increase the optimization level your program will stall. Declare all global vars changed in an interrupt handler as "volatile" or they might get optimized-out of your while(!flag)Wait();

   

 

   

Bob

View solution in original post

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

Welcome in the forum, dzone!

   

Two things I can see.

   

1st: You call frequently DMA_Config() which allocates resources (DMA channels, TDs) but you never free those. When you declare the Channel and the TD as global, you might re-use them instead of freeing and re-allocate.

   

2nd: You did not get the error yet, but when you increase the optimization level your program will stall. Declare all global vars changed in an interrupt handler as "volatile" or they might get optimized-out of your while(!flag)Wait();

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Many thanks Bob!

   

I can find the solution is using CyDmaTdFree everytime as you say.
And I had forgotten using volatile. You are great teacher!

   

thanks,
dzone.

0 Likes