How to convert ADC (with DMA) sample number to time without assuming uniform conversion time?
I'm new to working with ADCs on STM32. I'm reading a rectified voltage using ADC with DMA on an STM32G0B1. I know the ADC conversion time from the datasheet but I want to compare the ADC's output with readings from an oscilloscope. I'm plotting the voltage captured on the oscilloscope for 0.5 s and wish to compare this with the ADC output.
I'm using the ADC in continuous conversion mode with DMA. The clock prescaler is set to "Synchronous clock mode divided by 2" and the sampling time is 1.5 cycles. I'm storing samples in a 2000-length buffer.
However, on the project I'm working, I'm being told not to assume uniform conversion time between samples. If that would've been the case, I would've directly converted the sample numbers (i.e. indices) to units in time. Rather, I'm told to measure the conversion time between samples using a timer (say TIM16). I have tested the conversion time for the DMA mode on an oscilloscope by setting a GPIO pin HIGH when the conversion is complete.
How can I measure the conversion time between samples so that I can plot the oscilloscope voltage and ADC output on the same graph? I know the timescales of both graphs would differ, but the fundamental objective is to convert the sample number to a dimension in time without assuming uniform conversion time. Would measuring the conversion time b/w samples (in microseconds) for the ADC with DMA using timers be the optimal approach? If yes, between which functions/events in HAL_ADC_xx should I trigger a timer?
