2 Replies Latest reply on Mar 24, 2016 6:01 PM by userc_40331

    cannot run DMA2 after 52 times

      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.



        • 1. Re: cannot run DMA2 after 52 times

          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();





          • 2. Re: cannot run DMA2 after 52 times

            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!