2024-04-06 09:23 AM
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!!
2024-04-09 01:28 AM
Any thoughts from the community? :)
2024-04-18 01:42 AM
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