An5537 How To Use Adc Oversampling Techniques To Improve Signaltonoise Ratio On Stm32 Mcus Stmicroelectronics
An5537 How To Use Adc Oversampling Techniques To Improve Signaltonoise Ratio On Stm32 Mcus Stmicroelectronics
Application note
Introduction
All STMicroelectronics microcontrollers embed an ADC (analog-to-digital converter) with a given resolution (number of bits) and
sampling rate.
For most applications, this resolution is sufficient, but in some cases where a higher accuracy is required, oversampling, and
decimating the input signal can be implemented to avoid the use of an external ADC solution and the associated increase in
application power consumption.
This application note presents the oversampling principle, then describes hardware and software oversampling implementation
using a specific unit that is available on certain STM32 MCUs. It then compares the two possibilities in terms of power
consumption.
For the software implementation, two ADC resolution improvement methods are described. These are based on oversampling
the input signal with the maximum sampling rate of the ADC used, and decimating the input signal to enhance its resolution.
The embedded software (STSW-STM32014 or X-CUBE-ADC_OVSP) delivered with this application note gives implementation
examples for these two methods, and applies them to both medium- and high-density STM32F1 series products, as well as all
STM32F3 series and STM32Lx series products.
For the hardware implementation, an overview of the on-chip hardware analog-to-digital converter (ADC) oversampling engine
is provided. It is integrated in the STM32 products listed in Table 1.
The main user benefit of hardware oversampling is increased SNR (signal-to-noise ratio) with less CPU interaction, resulting in
overall lower power consumption compared with the software-based implementation.
Formulas are provided to determine the oversampling ratio or the hardware oversampling unit configuration to use according to
the desired resolution improvement. These theoretical formulas are compared to practical use cases.
Type Series
STM32U5 series, STM32U0 series, STM32H7 series, STM32H5 series, STM32F7 series, STM32F4 series,
Microcontrollers STM32F2 series, STM32F0 series, STM32L1 series, STM32F3 series, STM32F1 series, STM32L4+ series,
STM32L4 series, STM32L0 series, STM32L5 series, STM32G4 series, STM32G0 series, STM32WB series
1 General information
Digital output
Analog
input e(t)
slope: a
+ q/2
t
- q/2
Quantization error
+ q/2
- q/2
Transfer function
2 a ⋅ − q / 2a e t 2 ⅆt = q
e t = (3)
q q/ 2a 12
The SNR (signal-to-noise ratio) is the ratio of the ADC noise to the input signal power. For an ideal ADC, it is
assumed that the SNR is equal to the ratio of the quantization noise to the input signal. No other noise source is
considered.
For a full-scale input sine wave this is expressed as follows:
s t = q × 2 N − 1 × sin 2πft (4)
Using equations (3) and (4), the SNR of an ideal N-bit converter (ADC resolution) is calculated as follows:
SNR = 6.02 × N + 1.76 dB (5)
It is important to note that the RMS quantization noise is measured over the full Nyquist bandwidth (from DC up to
Fs/2).
It can be seen that when the SNR increases, the ADC effective number of bits (N in the equation 5) increases.
Note also that for a real ADC, different error sources must be considered: offset, gain - INL (integral nonlinear)
and DNL (differential nonlinear). A brief description of these errors can be found in the STM32 MCU datasheets.
These errors degrade the ideal ADC resolution and determine the real effective number of bits of the ADC
(ENOB). Improving the SNR enhances the effective number of bits of the ADC. The following section
demonstrates that sampling the input signal rates higher than the Nyquist frequency improves the SNR. The
Nyquist frequency is discussed in the next paragraph.
q / 12
Fs/2
f
0 BW Fs/2
However, under certain conditions where the sampling clock and the signal are harmonically correlated, the
quantization noise becomes correlated. In addition, its energy is concentrated in the harmonics of the signal. In
conditions where the quantization noise does not appear as random noise, dithering must be applied (see
Section 2.4 Dithering).
In many applications, the useful signal occupies a bandwidth (BW) smaller than Fs/2.
If digital filters are used to remove the noise outside the BW (this filter can be more precise than the antialiasing
ones mentioned before), the total RMS noise is reduced (Figure 3); the RMS value of the quantization noise is
divided by a ratio that depends on the useful bandwidth (BW) with respect to the sampling rate (Fs).
q / 12
RMS value =
Spectrum Fs/2
BW
q / 12
Fs/2
f
0 BW Fs/2
We can then reformulate the previous SNR expression taking into account this processing gain, by filtering the
out-off band noise:
SNR = 6.02 × N × + 1.76 dB + 10xLog10OSR (6)
This expression is valid over a bandwidth, BW, with an oversampling ratio given by:
OSR = FS/ 2 × BW (7)
2.4 Dithering
The technique presented above works well for a white quantization noise.
However, if the sampling clock and the signal are harmonically correlated (in this case the quantization noise
becomes correlated as well), or when the input signal amplitude is smaller than q/2, the processing gain does not
work properly.
This is because for the first case the quantization noise is no longer random, and for the second case there are (in
theory) no code transitions when the signal is smaller than the quantization step.
One way to solve these issues is to use the dithering technique, where a small Gaussian noise is added to the
input signal (see the left side of Figure 4), to obtain a signal (see the right part of the figure) that can ensure LSB
toggling.
Dithering also ensures that the quantization noise is always random, independently from the input signal.
V V
+q/2
t
-q/2
The impact of SNR can be much reduced if the noise is shaped; for example if the dithering noise is filtered in the
wanted bandwidth, and is only present outside of that bandwidth.
The embedded DAC can be used for generating the dithering signal. Also, in Section 3.2 Oversampling using
triangular dither, we generate the dithering signal by means of a timer configured in PWM mode, and some
additional electronic components.
If the application does not require the capture of signals smaller than the quantization step, and if the quantization
error can be considered as wideband noise, the dithering technique can be omitted.
3 Software oversampling
This section presents two software-oversampling implementation methods. Each has advantages and
disadvantages, which are compared.
The embedded software delivered with this application note is available in the STSW-STM32014 (or X-CUBE-
ADC_OVSP) package.
3.1.2 Decimation
Averaging means adding m samples and dividing the result by m. Averaging several data from an ADC
measurement is equivalent to a low-pass filter, which attenuates the signal fluctuation and noise. Averaging is
therefore often used to smooth and remove spikes from the input signal.
Note: Normal averaging does not increase the resolution of the conversion because the sum of m N-bit samples
divided by m is an N-bit representation of the sample.
Decimation is an averaging method. When combined with oversampling, decimation improves the ADC
resolution.
In fact, adding 4p (4 power of p) ADC N-bit samples, gives a representation of the signal on N+2p bits. To have p
additional effective bits, the sum is shifted to the right by p bits.
This FIR filter with equal filter coefficients enables the user to filter the oversampling frequency by giving an output
sample computed from the OSR input samples.
The oversampling method limits the maximum input frequency bandwidth. In the case of the STM32F1 series,
STM32F3 series and STM32Lx series (with maximum sampling rate around 1 Msps), signals having components
up to 500 kHz can be processed by the ADC. If for example, two additional resolution bits are required, the
maximum input frequency is 500 kHz/16 = 31.25 kHz when the oversampling uses white noise.
In the case where an external noise dither must be added to the input signal, the thermal noise generated by a
diode or a resistor can be injected into the input signal.
The input noise must not correlate with the useful input signal, and the input signal should have an equal
probability of being between two adjacent ADC codes. This means that this method does not work for systems
using a feedback process.
The ADC thermal noise can be computed from this histogram (although this can be shown, it is not the objective
of this application note and the details are not offered here).
To carry on this ADC noise test, the user must do the following:
• Uncomment the line #define Themal_Noise_Measure in the oversampling.h file.
• Configure the Total_Samples_Number which is the number of ADC conversion operations. It must be
smaller than 65535. The DMA channel is configured to store the number of ADC samples in a RAM buffer.
At the end of the transfer, an interrupt is generated and the number of occurrences of each ADC code is
computed.
• To compute the occurrence of the ADC codes, a variable giving the relevant ADC codes is defined.
When the code is run, Relevant_ADC_Samples ADC samples and their corresponding number of occurrences
are displayed on the HyperTerminal. The HyperTerminal configuration is 8-bit data, no parity, 115 200 baud rate. If
the effective number of ADC samples found is smaller than the defined Relevant_ADC_Samples variable, then
0 is displayed for both ADC code and ADC code occurrences. The user can capture them and build a histogram.
ADC period = 1 µs
<=1µs
Time t
The oversampled datum is computed in the DMA transfer complete interrupt. For synchronization reasons, it is
recommended to read it in the second TIM2 interrupt. Note that with this implementation, the TIM2 period must be
greater than the time required by the ADC to convert OSR samples, and greater than the ADC interrupt execution
time.
If the sampling frequency required by the application is exactly OSR μs, then the user is not required to use the
timer TIM2 to generate the input sampling frequency. However, the DMA must be configured to be functional in
continuous mode and the DMA transfer complete interrupt must be updated accordingly. The oversampled datum
is usually computed in the DMA transfer complete interrupt.
3000
2500
2000
1500
1000
500
0
120
150
180
210
240
270
300
330
360
390
30
60
90
0
6000
5000
4000
3000
2000
1000
0
123
164
205
246
287
328
369
410
451
492
533
574
615
656
697
738
41
82
0
779
111 000 q1
Input signal @ q0+0.6LSB
110 111
110 110 Input signal + triangular
waveform samples q1
110 101
110 100 (q1+q0)/2
110 011
Input signal + triangular
110 010 (q1+q0)/4
waveform samples q0
110 001 (q1+q0)/8
110 000 q0 Average of q1 occurrences= 9/16 = 0.563
-> The nearest value is 110 101
Result =(7x110 000+ 9x111 000 + 1) >>1=110 101
If the input signal is not correlated with the triangular waveform, then it is demonstrated that the gain in the SNR is
equal to:
SNRGain = 20 log OSR (9)
2
Therefore, each doubling of the sampling frequency improves the SNR by 6 dB and adds 1 bit of ADC resolution.
In general, to add p-bit extra resolution, the oversampling frequency must be equal to:
FOVS = 2 ⋅ 2pFs (10)
• The input signal must not be changed after the op-amp. For this reason, R1 should be equal to R3.
• The sum of the input signal and the triangular dither is inverted. For this purpose, a 3.3 V offset is required
on the positive entry of the op-amp. After the oversampled data are computed, this offset is subtracted to
give the input signal estimation with an extra resolution.
R1 R3
Input signal 10k 10k
1k
ADCperiod=1µs
TIM3period=ADCperiod=1µs
TIM3CCR1registerv aries duringOSR period(OSR=4inthisexample)
Input signal
Timet
DT53490V1
Samplingper iod= TIM2per iod
For this method to work, the input signal must not vary by more than ±0.5LSB during the oversampling period.
This means that for STM32F1 series, STM32F3 series or STM32Lx series devices operating from a 3.3 V VREF+,
the maximum allowed variations of the input signal during the oversampling period is ~0.4 mV.
On the other side, a triangular waveform with an amplitude of 0.5 LSB means a 0.4 mV amplitude when operating
the STM32F1 series, STM32F3 series or STM32Lx series from a 3.3 V VREF+. The application environment must
therefore not be very noisy. Any disturbance of the triangular waveform has an impact on the computed
oversampled data.
According to the implementation, the triangular waveform is generated by means of the STM32 timer and an RC
filter that cuts the 1 MHz timer frequency. The timer PWM output signal is integrated to provide a triangular signal
with a 3.3 V amplitude. The division is done with the ratio R3/R2.
The embedded software related to this method is located in the TriangularDitherMethod directory.
Table 2. Oversampling using white noise versus oversampling using triangular dither
Implementation conditions Oversampling using white noise Oversampling using triangular dither
Implementation conditions Oversampling using white noise Oversampling using triangular dither
3.4.1 What is the maximum number of bits that can be added to the on-chip ADC resolution?
It can be easily shown that increasing the on-chip ADC resolution decreases the maximum frequency component
of the input signal.
For example, when using the STM32F1 series, STM32F3 series or STM32Lx series ADC at 1 MHz and two
additional bits are required by the application, then the maximum input frequency is divided by:
• 16 when using the white noise method (62.5 kHz)
• 4 when using the triangular dither method (125 kHz).
For the two methods, the estimation of the input signal is done during an oversampling period of OSR times the
ADC conversion rate. In the case the ADC is running at 1 MHz, the input signal estimation is done over OSR μs.
The signal must not vary by more than 1/2LSB for the white noise method and, by ±0.5LSB for the triangular
waveform method.
• When using the white noise method, the maximum number of bits that can be added to the ADC resolution
depends only on the input signal.
• When using the triangular dither method, the maximum number of bits that can be added to the ADC
resolution does not depend only on the input signal. In fact, the steps defining the triangular signal depend
on the ADC and APB frequencies. The timer period should be equal to the ADC rate:
– 2x(2p) ≤ timer period
– P ≤ log2 (timer period / 2)
In our example, running the ADC with a rate of 1 μs causes the STM32F1 series to operate at 56 MHz, which
means that the timer period must be equal to 55. The maximum number of bits that can be added in this case is
4.
3.4.3 Taking advantage of the STM32F1 series, STM32F3 series and STM32L4 series dual ADC mode
implementation
In some STM32F1 series, STM32F3 series and STM32L4 series devices, the dual ADC mode is an interesting
feature that allows two ADCs to convert at the same time. Using the dual ADC fast interleave mode, the same
channel is converted alternately by ADC2 and ADC1. The time separating two successive samples is 7 ADC
clock cycles. The input signal is therefore oversampled faster. In the example described in this application note, a
sample is obtained every 1 μs. Using the dual ADC fast interleave mode, it is possible to have a sample every 7
ADC clock cycles that is every 0.5 μs when running the ADC at 14 MHz.
Note: This hint is not implemented in the software given within the application note.
4 Hardware oversampling
This part presents the hardware oversampling unit available in the products listed in Table 1. Applicable products.
The main benefit that the user can get from the hardware oversampling is increased SNR (signal-to-noise ratio)
with less CPU interaction, resulting in overall lower power consumption compared with the software-based
implementation.
-10
-20
Magnitude (dB)
-30
-40
-50
-60
-70
-80
-90
0 100 200 300 400 500
Frequency (kHz)
Although this is not a perfect low-pass filter, the very high attenuation of the sampling frequency is a useful
property. It is effective in canceling the out-of-band noise resulting in an increased signal-to-noise ratio.
The ADC oversampling method can be implemented by hardware or by developing a dedicated software routine.
The advantage of hardware implementation is that the total energy budget needed for processing the ADC
acquired samples is reduced in comparison to the software implementation where all the data processing needs
to be done by the core. However, the hardware oversampling unit is not available on every product.
Two test projects emulating the common data acquisition tasks have been developed and executed on the same
system to evaluate the energy difference and to demonstrate how much energy can be saved by using the
hardware oversampling.
5.3 Results
The energy consumption for the data acquisition and processing task, and the average current consumption for
the whole 100 ms period for both demonstration projects are detailed in Table 3.
The hardware oversampling implementation can save about 20% of the energy consumed to complete the
acquisition and data processing task with lower coding effort and CPU time.
The formulas to apply for a desired resolution improvement using each method are presented in the table Table 4.
Formula
Method
(X is the ADC resolution OSR is the oversampling ratio)
In practice, this resolution never reaches its theoretical value. A good indication of the efficiency of an ADC is to
determine its ENOB (efficient number of bits). This parameter can be considered as a 'real-life' resolution that
takes into account potential noise, distortion, and circuit imperfections. It also gives a good indication of its
dynamic performance.
It is good practice to measure this parameter to verify that the resolution of an ADC is not degraded too much by
its implementation and configuration.
The ENOB can be determined by several methods. In the context of this document, a formula that links it to two
other parameters is used: SINAD (signal-to-noise and distortion ratio) and THD+N (total harmonic distortion +
noise).
The formulas are as follows:
ENOB = SINAD − 1.76 + 20log Full_scale_amp/Input_amp /6.02 (12)
ENOB = THD + N − 1.76 + 20log 10 Full_scale_amp − Input_amp /6.02 (13)
Full_scale_amp is the maximum amplitude that can be measured by the ADC.
Input_amp is the amplitude of the signal applied to the ADC.
These formulas result directly from equation (5). The difference is that noise and distortions are taken into
account by replacing the SNR by the SINAD or the THD+N, making it closer to a real-life situation. The amplitude
of the input signal used for ENOB measurement is also taken into account thanks to the ratio Full-scale amp./
Input amp. Indeed, if the amplitude of the input signal does not fill the full amplitude reading ability of the ADC,
this has to be considered when computing a ratio featuring the level of this signal.
Note: If the bandwidth of the measurement is DC to Fs/2 (the Nyquist bandwidth, Fs is the sampling frequency), THD
+ N is equal to SINAD. That is what we consider for the two formulas above.
The following steps can be followed to measure the ENOB of an ADC:
• With a high precision signal generator, inject a sinusoid on one of the tested ADC channels with a
frequency respecting the maximums given in Table 2. Oversampling using white noise versus oversampling
using triangular dither for software oversampling, or fADCmax/(2*N) for hardware oversampling with N
being the oversampling ratio of the oversampling engine. The sinusoid amplitude should be 90% of the
ADC full-scale to avoid saturation.
• Configure the ADC to acquire some samples of the signal. The best is to get a rounded number of the
signal period. 4096 is a good example but might need to be adjusted in function of the frequency of the
input signal.
• Make the successive binary codes operated by the ADC available for measurement (parallel/serial
transmission, file recording…).
• Analyze the ADC measured signal with a frequency analyzer capable to do SINAD or THD+N
measurement.
• With the SINAD or THD+N measurement features, get the value for one of these two parameters.
Measuring both parameters enable doing a comparison of the ENOB values obtained.
• Apply the formula to determine the ENOB of the ADC (see Eq. (12) or Eq. (13)).
To provide practical data and be able to analyze the effect of oversampling on the ENOB, the above steps have
been followed with the following equipment and tools.
The input sinusoid has been generated with the analog output of the Audio Precision AP2722 Audio Analyzer.
Several input frequencies have been tested to analyze the effect on the ENOB obtained. The signal output by the
AP2722 is 0-centered, so a conversion stage is needed to set its amplitude between 0 and 3.0 V
(VDD=VDDA=3.3 V on STMicroelectronics EVAL and Nucleo boards).
Note: This conversion stage behaves like an HP filter and influences the signal measured by the ADC (lower signal
resolution for lower frequencies). This can give a good representation of a real-life use case.
The STM32L476G-EVAL board has been used to process the ADC measurement and transmitting/recording it.
The ADC sampling is done on the pin PA4 linked to the STM32L4 ADC1 Channel 9 and to ground through a
4.7nF capacitor to filter high frequency noise. This pin is available on the connector CN7 of the EVAL board.
The application running on the STM32L476G-EVAL board saves 4096 ADC samples in RAM thanks to the DMA
peripheral.
The oversampling unit is used to analyze its effect and configured as presented in table 6.
A timer is set up to trigger the transfer of each sample (even the ones used for oversampling). The frequency of
this timer is adjusted according to the oversampling configuration wanted.
When the 4096 samples are saved, they are transferred through the STM32 UART interface to be recovered in a
file on a PC thanks to a Python script.
The resulting file is formatted so that it can be processed with MATLAB®.
The sampling rate chosen for the test is 12.5 kHz (when oversampling is used, this is the final sampling rate) to
be able to keep a constant ADC clock frequency (80 MHz) and sampling time (12.5 cycles).
MATLAB® enables computing the SINAD or THD+N of the ADC signal. It has a native sinad function that is used
to analyze the ADC signal saved into the file created previously. Then, applying eq.X gives us the ENOB
measured.
To emphasize oversampling effects, each oversampling ratio possible has been tested while fixing the right shift
coefficient to target the best resolution offered.
Table 5 presents the resolution that can be achieved in function of the oversampling ratio and the right shifting. 16
bits have been targeted. For the ratio values 2, 4 and 8 a left shifting (respectively by 3, 2 and 1 bit) has been
processed to achieve the 16-bite target.
Table 5. Theoretical ENOB values for hardware oversampling unit versus configuration
2 13 12 11 10 9 8 7 6 5
4 14 13 12 11 10 9 8 7 6
8 15 14 13 12 11 10 9 8 7
16 16 15 14 13 12 11 10 9 8
32 17 16 15 14 13 12 11 10 9
64 18 17 16 15 14 13 12 11 10
128 19 18 17 16 15 14 13 12 11
256 20 19 18 17 16 15 14 13 12
1. Bold entries have no significance since the hardware oversampling unit output is limited to 16-bit data width.
Table 6. Practical ENOB measurement with the hardware oversampling unit versus configuration
2 13 12 11 10 9 8 7 6 5
4 14 13 12 11 10 9 8 7 6
8 15 14 13 12 11 10 9 8 7
16 16 15 14 13 12 11 10 9 8
32 - 16 15 14 13 12 11 10 9
64 - - 16 15 14 13 12 11 10
128 - - - 16 15 14 13 12 11
256 - - - - 16 15 14 13 12
1. Bold entries have no significance since the hardware oversampling unit output is limited to 16-bit data width.
Table 7. Practical ENOB measurement with the hardware oversampling unit versus configuration
2 - - 12 -
4 13 - 13 -
8 - - 14 -
16 14 - 15 -
32 - - 16 -
64 15 - 17 -
128 - - 18 -
256 16 - 19 -
As mentioned before, the signal test input is a 3.0Vpp sinusoid and the sampling rate is 12.5 kHz. Thus, to
respect the Nyquist criteria, the following frequencies have been tested: 500 Hz, 1 kHz, 1.5 kHz, 2 kHz, 2.5 kHz.
ENOB
OVS ration OVS right shift OVS left shift
500 Hz 1 kHz 1.5 kHz 2 kHz 2.5 kHz
Note: For reference, after the conversion stage and at the ADC pin level, the following THD+N values were measured:
-82.5 dB at 500 Hz (this is equivalent to 13.55 ENOB according to eq. Y), -93 dB at 1 kHz (15.29 ENOB), -96 dB
at 1.5 kHz (15.79 ENOB), -97 dB at 2 kHz (15.96 ENOB) and -98 dB at 2.5 kHz (16.12 ENOB). At the audio
precision analyzer output, which is before the conversion stage, -105 dB were measured (17.28 ENOB).
In the STM32L476 datasheet, it is given that the typical ENOB of the ADC is 10.5 (the ADC is configured as
single-ended).
Thus, Table 8 shows that it is possible to get over this typical value and even over the real ADC resolution.
However, the theoretical 16-bit target stays far from the results and corresponds more to an idea of the
performance of the oversampling configuration.
The result also highlights that a higher oversampling ratio gives a better ENOB despite limiting the sampling
frequency and so the input signal frequency.
7 Conclusion
This application note has explained the basics of the oversampling technique used to improve the SNR
performances (and thus the effective resolution) of ADCs integrated in most of the STM32 microcontrollers.
The cornerstones of the oversampling technique are:
• The RMS quantization noise of an ADC is q / √(12), over the Nyquist bandwidth (q is the ADC quantum:
LSB value)
• If the wanted bandwidth is smaller than the Nyquist bandwidth, the quantization noise is reduced in
proportion by using a filter to remove the out of band noise
• Dithering can be used if the quantization noise does not behave like a wideband noise
The hardware implementation of the ADC oversampling technique reduces the time and energy needed by the
CPU for the data processing tasks. It results in lowering the overall power consumption.
When the hardware oversampling unit is not available on the STM32 used, it is still possible to implement entirely
the technique via software as it has been presented in this document.
The effect of oversampling on the effective ADC resolution (ENOB) has also been analyzed. With oversampling it
is possible to get the effective resolution over the real one.
Revision history
Table 9. Document revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 Oversampling as a way to improve the quality of signal acquisition . . . . . . . . . . . . . . . . 3
2.1 Quantization of noise and signal-to-noise ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 Nyquist theorem and antialiasing low-pass filter relaxation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Processing gain achievable with oversampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.4 Dithering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Software oversampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1 Oversampling using white noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.1 Oversampled signal SNR with white input noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.2 Decimation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.3 When is this method efficient?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1.4 Implementation method on STM32F1, STM32F3, and STM32Lx series devices. . . . . . 8
3.2 Oversampling using triangular dither . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.1 When does this method work? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.2.2 Implementation method on STM32F1, STM32F3, and STM32Lx Series devices . . . . 12
3.3 Comparison of software oversampling methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 Hints for software oversampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.1 What is the maximum number of bits that can be added to the on-chip ADC resolution? . 15
3.4.2 Taking advantage of the STM32 DAC implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.3 Taking advantage of the STM32F1 series, STM32F3 series and STM32L4 series dual ADC
mode implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.4.4 Taking advantage of the hardware ADC oversampling implementation . . . . . . . . . . . 16
4 Hardware oversampling. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17
4.1 Hardware oversampling feature overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 Hardware versus software oversampling comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
5.1 Software implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.2 Hardware implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.3 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
6 ENOB (effective number of bits) measurement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
7 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
List of tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
List of figures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .28
List of tables
Table 1. Applicable products . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
Table 2. Oversampling using white noise versus oversampling using triangular dither . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Table 3. Comparison of SW and HW implementation of ADC oversampling technique. . . . . . . . . . . . . . . . . . . . . . . . . . 19
Table 4. Formulas for ENOB improvement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Table 5. Theoretical ENOB values for hardware oversampling unit versus configuration . . . . . . . . . . . . . . . . . . . . . . . . 21
Table 6. Practical ENOB measurement with the hardware oversampling unit versus configuration . . . . . . . . . . . . . . . . . 22
Table 7. Practical ENOB measurement with the hardware oversampling unit versus configuration . . . . . . . . . . . . . . . . . 22
Table 8. Effect of oversampling on ENOB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Table 9. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
List of figures
Figure 1. Ideal N-bit ADC quantization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 2. Quantization noise spectrum . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 3. Quantization noise gain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 4. Dithering technique . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 5. Histogram analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 6. Histogram analysis for DC = 1.65 V . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Figure 7. Oversampling using a white noise flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 8. Ramp samples with 1 additional bit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 9. Ramp samples with 2 additional bits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 10. How to perform oversampling by adding a triangular signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 11. Hardware requirements of oversampling by adding a triangular signal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 12. Oversampling using triangular dither flowchart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 13. Frequency response of accumulate-and-dump filter. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18