cancel
Showing results for 
Search instead for 
Did you mean: 

I can't combine settings correctly with HAL. ADC_scan+DMA+Timer_trigger

DPr
Associate

I need to get data from 2/4 regular channels of ADC1 at every TIM4_CC4 event and save it with DMA. But always every time I receive ADC OVR error.

0690X000006CUnGQAW.png0690X000006CUn1QAG.png0690X000006CUnBQAW.png0690X000006CUn6QAG.png

When I start ADC with HAL_ADC_Start_DMA I receive 1 immediate conversion with transfer. Then I start TIM and with the fisrt event receive ADC_OVR, then conversion starts at every event, but DMA doesn't work.

I've tried a lot of combinations of ADC and DMA settings (Cont./discont. modes, circular/normal, EOC at every conversion/at the whole conversion). I've also tried to configure DMA manually, then to start ADC with HAL_ADC_Start and HAL_ADC_Start_IT commands. But none worked.

How to configure it right due my goal?

2 REPLIES 2

And you're using what part? STM32 describes hundreds of different parts.

Typically DMA would be circular, and have a buffer of adequate depth to hold all the samples.

The ADC_OVR is indicative that the DMA is not running, or the wrong channels/streams have be selected or not plumbed correctly. Make sure the TIM period is sufficient to allow for all the conversions to occur.

The TIM should trigger the ADC, the ADC should trigger the DMA. The DMA needs to read the ADC Data Register.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Thanks for reply.

I use STM32F405RGT6.

Tim period is about 1 second and AdcConversionCompleteCallback is executed with the same period, but DMA is automatically disabled after the first ADC_OVR error.

DMA Stream is correctly chosen by Cube and works properly, but only when HAL_ADC_Start_DMA function is called. That's interesting, because I still don't know why conversion and transfer is called this moment, because there swstart bit is set only if ADC is triggered by software. Only then I call Timer start. Using delay between ADC and timer start I've made sure that the second time and later ADC is triggered exactly by timer event.

Maybe I have to use custom code to config adc+dma and launch it istead of HAL_ADC_Start_DMA.