cancel
Showing results for 
Search instead for 
Did you mean: 

STM32G070 Fastest time for ADC continuous mode data sampling

YChen.9
Associate II

Hi,

I am using the continuous mode of the ADC to continuously sample a channel and transfer the data by DMA. I have set the ADC frequency to 32 Mhz , and the sampling CLK to 3.5 CLK. According to the manual , the whole sampling conversion time should be 0.5us. But based on the difference between the data I got  and the actual waveform, I assume that the interval between each data is much longer than 0.5us.

What I want to confirm is whether the ADC is able to do the sampling interval up to 0.4us(The manual claims that) in continuous mode. if not, how should the time be calculated.

Thanks

5 REPLIES 5
TDK
Guru

The manual is correct. You'll have to use DMA and continuous conversions to achieve this speed. Show your code.

> much longer than 0.5us.

How long? How are you calculating this?

If you feel a post has answered your question, please click "Accept as Solution".

Hi,

I use cubemx to configure my demo, here is my configuration

ADC.pngCLK.pngDMA.png

Here is my code

code.png:

About how I measure time intervals:

I'm measuring a PWM waveform with about 40us cycles and 25% duty . I am setting a sampling time of 0.5us, so there should be at least 80 data intervals between waveforms. But that's not the actual data I'm getting. There is no way to match the waveforms to the data obtained.

dat.pngWAVEFRORM.jpg

 

 

Carl_G
Senior

Your sampling time is set to 0.109uS.
Your total conversion time is set to 0.500uS.

You have a 32-bit array it seems but you have set your conversions to 1/2 word or 16-bit. I think these should match. Either change your array to 16-bit, or change your memory data width in your DMA configuration to Full Word.

This will interact with your 1400 size limit.

I can't account for all the blank entries however. DMA shouldn't put an entry unless the ADC completed a conversion.

Hi,

Indeed, I found out that the problem really wasn't the sampling time, but that the data had a lot of zeros in positions where they shouldn't be. Changing the sampling time improves this, but longer sampling times don't make it better. Rather, a specific time improves it a lot. That's confusing too.

Your array appears to be 16-bit in your debugger screen so I got that wrong. DMA size is good. Well as long as it's aligned on 16-bit boundary. You don't show your array creation code.

Your problem seems like aliasing but really I don't expect 0s ever based on your scope plot. Do the "hairs" in your scope plot correspond to your ADC sample rate? They really shouldn't if you're only sampling a single channel. What's your input circuitry look like? Also, I think the DMA buffer should be volatile.