AnsweredAssumed Answered

Memory Corruption when Writing to DMA CITER

Question asked by Benjamin Schroeder on Mar 15, 2016
Latest reply on Mar 16, 2016 by Benjamin Schroeder

I'll be honest in that this has me pretty stumped.

 

So with my application, I am capturing edges via the FTM.  Every edge generates a DMA request to save the counter into a circular buffer.

I currently have the DMA configured to act as a circular buffer in case I don't get to the edges in time if they come in too fast.  However, every time I check the edges, I want to reset the DMA pointer, and I do this by writing to CITER.

 

For instance, my circular buffer has 128 elements.  When I check my buffer, I execute the following line of code:

DMA0->TCD[0].CITER_ELINKNO = 128;

 

This works for a little while, but I noticed after my program has been running for a bit, all of a sudden all of my variable blow up to crazy values, and it seems like there was an illegal jump or something.  I'm not able to really figure it out because when I single step through my code, the corruption never happens.

 

Is what I'm doing fine?  Is there an application note somewhere that tells me I shouldn't do this?

 

Thanks.

 

Edit: I forgot to mention, I also tried disabling the DMA channel before and after modifying the CITER register, but this does not seem to help either.

DMAMUX0->CHCFG[0] ^= ~(DMAMUX_CHCFG_ENBL_MASK);

 

Also, I'm using the TWR-K60F120M.

Outcomes