cancel
Showing results for 
Search instead for 
Did you mean: 

I'm doing ADC readings with DMA into a regular (non-circular) buffer but I always get the overrun bit set in the ADC status register even though I stop the DMA immediately in HAL_ADC_ConvCpltCallback.

EMarq.1
Associate II

I want to read ADC values with DMA at specific times (I have an analog multiplexer that needs to switch and I want to synchronize the ADC readings with the mux switching). I have the ADC triggered by a timer and stop the ADC immediately using HAL_ADC_Stop_DMA when I get HAL_ADC_ConvCpltCallback. If I set a breakpoint right after HAL_ADC_Stop_DMA I see both the Overrun and Start bits are set in the ADC status register. I'm using a Normal rather than Circular buffer. Any ideas why the start and overrun bits are set? Thanks

2 REPLIES 2

> stop the ADC immediately using HAL_ADC_Stop_DMA when I get HAL_ADC_ConvCpltCallback

Depending on how fast you trigger the ADC conversions, this may be too late and a new conversion may have already started.

Is this a problem? You can probably just clear the ADC flags and proceed. Otherwise, you need to emit a precise number of triggers from the timer, e.g. by gating it by another trigger using the TRGO-TRGI mechanism.

JW

EMarq.1
Associate II

Hi JW, thanks for your reply. It turned out not to be the problem, but it prompted me to go through the low level DMA code to try to get a rough idea of how long the stop process would take. In the process I discovered an error being generated by HAL_ADC_Stop_DMA which turned out to be "no transfer in progress". Apparently, when the destination buffer is filled and you're not in circular mode, the DMA is automatically stopped and trying to stop it again messes things up. I just deleted the HAL_ADC_Stop_DMA command and everything seems to work fine now.