cancel
Showing results for 
Search instead for 
Did you mean: 

HAL_ADC_Start_DMA from HAL_ADC_ConvCpltCallback

mgiordyeth
Associate

Hi :)

I would like to acquire n samples from one channel of the on-board ADC (set at 4MHz) every time my EXTI line gets a rising edge (about 25Hz). I am on a STM32L496 on its Nucleo board.

I am using ADC1 IN8 single-ended and I am using Regular Conversion as EXTI trigger. I have Continous Conversions enabled and DMA enabled as well.

I am starting the conversion with `HAL_ADC_Start_DMA` from the main, which saves the data in a buffer and calls the `HAL_ADC_ConvCpltCallback` once the conversion is done. Now I would like to restart the conversion from the interrupt, but if I call `HAL_ADC_Start_DMA(hadc, ...);` from inside the interrupt I don't get any more conversions. On the other hand, if I call again `HAL_ADC_Start_DMA` from the main the system works as intended.

Can I restart the conversion inside the Callback? Is this even the right way to do it?

Thank you!!

2 REPLIES 2
mgiordyeth
Associate

Any thoughts from the community? :)

RAJMAI
ST Employee

Hello @mgiordyeth,

In your situation, I believe the optimal approach would be to employ the DMA in circular mode, which eliminates the necessity to restart the ADC.

You can reference the ADC_DMA_Transfer example as a guide. By enabling the circular mode, you would set the DMA mode as follows:

 

 

DmaHandle.Init.Mode = DMA_CIRCULAR;

 

 

Regards,

Rania

If your question is answered, please close this topic by clicking "Accept as Solution".

Thanks
Rania