17tmh
17tmh

Reputation: 63

STM32 ADC: Continuous conversion (DMA) vs. discontinuous conversion accuracy

I am writing code for a STM32G030 microcontroller. I'd like to use the ADC on one input channel.

I observe, that the accuracy of ADC conversion results is way better in discontinuous conversion mode (= "manual" software trigger for each conversion) instead of continuous conversion mode (= single trigger to start and continuous result transfer to memory via DMA).

Here are some values for a 12 bit result:

min max
theoretical values 0 4095
discontinuous 3 4073
continuous 356 3567

ADC clock and and sampling time configurations are the same! Of course, with longer sampling times, I am able to get better results even in continuous mode. But I wonder where these big differences come from? Is this hardware related and usual in some way or am I missing soemthing about my ADC configuration?

Everything I have tried so far has not been able to mitigate the differences.

Update 2024-01-23:

Here is the schematic for the analog input:

enter image description here

I also did another experiment, this time I configured the STM32 to sample two analog signals multiple times, say 2 conversions per channel. So there are 2 times 2 = 4 "regular" ones. During one such sequence, the data is transferred from the DR to memory via DMA, but then I have to trigger the next sequence via software. The results are as follows: If I trigger the next sequence immediately, I get the same fuzzy results as with continuous DMA transfers, but if I insert a small pause (say 1 ms), the results are fine --- also within the sequence.

Any ideas?

Upvotes: 1

Views: 1240

Answers (1)

17tmh
17tmh

Reputation: 63

After some further experimentation, where I measured the voltage on the CPU pins with an external voltmeter, I found that the STM32 ADC results are always correct.

This means that fast conversions actually cause a change in the voltage on the pins, at least for the ADC input circuit on this board.

Modifying the ADC input circuit, e.g. with an operational amplifier, would be a possible solution here. However, as the high sampling rate is not necessary for the intended application, I will simply reduce it (without DMA).

Upvotes: 0

Related Questions