ADC is slow using HAL
I am measuring time time it takes to do ADC conversions on an STM32H753ZI Nucleo board, using the function function HAL_ADC_Start_DMA(). This converts 6 channels of ADC3, using 16 bits, with DMA. The one function call handles everything including DMA transfer. Then I am waiting for DMA to complete using interrupt handler HAL_ADC_ConvCpltCallback(). I am surprised how long this is taking and would like to ask if anyone has ideas on how to speed it up, or if perhaps this is expected. I set this up using CubeMX as follows:
ADC clock is10MHz. (I think max is 12MHz for 16bit ADC with LQFP144 package)
CPU clock is 100MHz.
ADC3 channels 0 thru 5 all have sample time 2.5 ADC clocks
ADC3 is set for 16 bits, conversion time = 8.5 ADC clocks I believe
This is a total of 11 ADC clock cycles, or 1.1usec
So for 6 channels total time should be about 1.1usec x 6 + DMA time, which should be 7-8usec. But the time I measure from HAL_ADC_Start_DMA() to HAL_ADC_ConvCpltCallback is about 40usec. I am compiling in release mode, with default optimization (-Os).
I normally avoid optimization but I tried -O2 and the measured time decreased to 28usec. I also tried a 200MHz CPU clock (ADC clock still 10MHz) and it decreased further to 22usec. But still this is slow compared with underlying hardware. Any thoughts are appreciated, and thanks for the help.
