AnsweredAssumed Answered

STM32F446 DMA Indexing

Question asked by Snyder.Joe.001 on Mar 22, 2017
Latest reply on Mar 24, 2017 by Snyder.Joe.001

I ultimately need "instant on" ADC conversions.  For instance, when a timing gate goes high, I need to start taking ADC values immediately (the signal is only 100us wide),  The problem I'm running into is the lag: firing up the ADC in DMA mode from a "cold start" takes 50+ usec to start getting values.  I tried leaving the ADC/DMA running, and just enabling/disabling interrupts, but even that takes ~25us from the point of enabling interrupts to getting values out.

 

The attached picture shows the dilemma: blue is the timing gate, yellow/purple is the signal I need to sample, and green is toggling when samples are being taken.  You can see that from the rising edge (when DMA interrupts are enabled) to getting samples takes ~25us. 

 

Now I've got the ADC/DMA dumping values into a 1000 element array (circular, continuous conversion).  That's working fine, but I need to be able to either 1: see what "index" the DMA is pointing to in the 1000 element array, or 2: be able to reset the pointer back to the beginning of the array.  i.e., I need to know where I'm at in the circular buffer at the rising edge of the timing gate.  I'm searching for examples, but everything seems to point to stopping the ADC/DMA and restarting it, which takes too long.  And I've found nothing on how to read out what index it is currently pointing at.

 

Ideally, I'd like to have 2 arrays, where the DMA dumps data to a "garbage" array, and at the rising edge of my timing gate, switch on the fly to the address of a "good" array.  However, section 9.5.8 of the STM32F446 reference manual says that the DMA stream x memory 0 address register (DMA_SxM0AR) can only be written if the stream is disabled. 

 

Any insight would be helpful.  Thanks in advance. 

Attachments

Outcomes