Or you can try to use external DMA triggers (wired to the timer output) (I never tried) they are only level sensitive.3. Use a SPI-based flash. This is not preferred as the capacities are lower (and in my testing they consumed more power, if I have enough RAM!)
Hi There,
Question:
Why does my DMA and Timer lose synchronization when the ADC ISR is enabled?
Information:
I did some work to achieve the behavior I wanted but have recently experienced a problem which has challenged my understanding. Let me explain. I am using the MSP430F5438A Rev F.
I have a parallel external flash IC and want to minimize the CPU and Flash power consumption by using DMA to transfer the data from the MSP430 to the external flash IC.
As the MSP430 does not provide an external transfer strobe (a line to show when the output has been updated by the DMA), I use a timer, sourced from MCLK, 8MHz, with two compare channels. One compare channel triggers the DMA to take a byte from RAM and place it on the parallel port (PxOUT). It is in repeated single transfer mode. After a few more clock edges the second compare channel is set. This timer output is routed out of the msp430 to the flash write pin using the PxSEL register. The delay between is to allow for the DMA to update the port. My settings are:
TA0CCR0 = 20; 21 edges in all TA0CCR3 = 19;//WE -> msp430 output TA0CCR2 = 1;//DMA Trigger
P8SEL |= 1<< WE; //output TA0CC3 on pin 8.3
This works well in isolation i.e. with the CPU not doing anything else.
The Issue
I also need to capture ADC data to fill the RAM buffer, which is then written to the flash when full. One method I have tried is to use the ADC ISR triggered by a different Timer and sourced from ACLK (which is Timer B). What I find is that occasionally the data gets corrupted, which I suspect is a loss in synchronization between the DMA and the Timer. The question is why is this happening?
What I have tried/thought:
I thought a repeated-single transfer takes 5 MCLK cycles + latency (i.e. 2MCLK cycles + 2 to synchronize + wait). I have 18 clocks between DMA trigger and the strobe. Also I thought that the DMA can interrupt the ISR - so the ISR shouldn't be hogging the clock. So what is causing this loss in synchronization? - what is causing the DMA to take longer than expected? I need to use repeated-single transfer to allow the ADC ISR to complete to maintain sampling.
I have tried to use the ADC with DMA and I believe this works. But I am worried as I don't understand the above scenario that I might have a hidden issue.
As I said, this has really knocked my confidence and I am concerned. Any suggestions/thoughts/discussion would really appreciated.