cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Conversion time for stm32h750vbt6 ?

A.Caliskan
Associate II

Hello,

I am trying to measure the adc cycle time with the help of an oscilloscope, what is the most precise and correct solution?, I would appreciate if you could help me what method should I follow to measure it.

23 REPLIES 23
Andrew Neil
Evangelist III

Seems to be just the same question as here:

https://community.st.com/s/question/0D53W00001GQSntSAH/stm32-adc-coversion-time-problem-

But the way to measure it, surely, is to set a pin when you start the conversion, clear it when the conversion completes, and measure the time on an oscilloscope?

I do it that way but the results are slower than expected. You can see how I did it in the post

So why are you asking in a separate thread?

That just confuses the issue!

Similar questions but not the same. So I don't think it will cause confusion.

raptorhal2
Lead

What is your "expected"? Did you account for overhead processing the interrupt and clearing the pin?

To get more precision, convert a large number of times before clearing the pin.

Cheers, Hal

Piranha
Chief II

> If you want to verify speed, do a bunch of conversions back to back, say 10000, use DMA to transfer, and measure the time it takes to complete.

The advice given by TDK in the other topic means that you should configure the ADC and DMA to capture an array of 10k samples automatically with a singe "transfer complete" interrupt at the end, not make 10k separate software-triggered conversions of a single samples as in one of your previous topics.

Let me solve your problems. I've done some calculations for example from your other topic:

0693W00000HpK64QAF.pngNote highlighted parts

Tsmpl=2.5 for LL_ADC_SAMPLINGTIME_2CYCLES_5

prescaler=2 for LL_ADC_CLOCK_ASYNC_DIV2

0.5*Srate*10^-3 for LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_0);

Note that LL_ADC_CLOCK_ASYNC_DIV2 halves frequency

and GPIO_TogglePin output halves frequency again. That's because GPIO level is high only each second sample. 892*2*2 ~ 3568 kHz ~ 3.5 Msps. To obtain 3.5 Msps try LL_ADC_CLOCK_ASYNC_DIV1, and note that GPIO toggling outputs half of actual frequency.

The precision problem may be related to scope. Some scopes do not measure frequency correctly, and the only way is to measure delay T using cursors and then calculate frequency using formula f=1/T

thanks for your answer,,892*2*2 ~ 3568 kHz ~ 3.5 Msps. I don't understand how this process works. how to halve the frequency(for LL_GPIO_TogglePin(GPIOB, LL_GPIO_PIN_0);).I think there is an error in the calculation.0693W00000HpKENQA3.png 

your formula is correct, but it is not 32*10e6, but 16*10e6

because LL_ADC_CLOCK_ASYNC_DIV2 results in division by 2:

fadc = fadc/prescaler =32 DIVIDE by 2 = 32 / 2 = 16 [MHz]

Now, about GPIO. Assume you have interrupt firing at 2MHz frequency. If we put LL_GPIO_TogglePin inside this interrupt, it requires two interrupts for full on/off cycle of GPIO pin. At 2MHz frequency, GPIO pin will be on for 0.5us, and off for 0.5us. Full on/off period is T=0.5+0.5=1 [us]. And frequency f=1/T=1/(1*10^-6)=1 [MHz].

To sum up, calling LL_GPIO_TogglePin inside interrupt with frequency F will result in GPIO output pin square wave signal of F/2 frequency (unless you call LL_GPIO_TogglePin two times inside single interrupt).