cancel
Showing results for 
Search instead for 
Did you mean: 

ADC DMA not work

HG LEE
Associate II

Hello

We ran the ADC DMA on the HAL example source. However, I tried to write the source in CUBEMX, When executed, the DMA interrupt is executed once and is not executed again.

Please let me know if I missed anything

1 REPLY 1
fbar
Senior

Yes, that example is written to execute only one transfer of the entire buffer and stop. If you want to execute more, you need to re-set the ADC and DMA properly for your use case. I'm not sure what's the logic behind those HAL functions, and why HAL_ADC_Start_DMA() doesn't properly clear the ADC registers before starting. But if you call HAL_ADC_Start_DMA() again, it will return an error, as I'm sure you have seen.

I could not find an HAL example where you can execute the same ADC/DMA transfer regularly (in my case, triggered by a timer), and I could not figure out a simple way to just clear the flags. Probably defining and using the right ADC callback functions the HAL clears the flag

I ended up directly programming the ADC and DMA registers, since for me the HAL created more problems than it solved when dealing with ADCs and DMAs. I needed granular control of the ADC/DMA interrupts and events, and frankly setting registers directly with the help of the LL libraries is pretty easy, definitely easier than bending my needs to the HAL way of doing things. I'm waiting for the next version of the H7 STM32Cube package, which is supposed to allow you to use LL libraries for everything. The funny thing is that the HDC HAL functions are de-facto using the LL functions.