Dm00150423 Adc Hardware Oversampling For Microcontrollers of The Stm32 l0 and l4 Series Stmicroelectronics
Dm00150423 Adc Hardware Oversampling For Microcontrollers of The Stm32 l0 and l4 Series Stmicroelectronics
Application note
ADC hardware oversampling for microcontrollers
of the STM32 L0 and L4 series
Introduction
This application note provides an overview of the on-chip hardware Analog-to-Digital
Converter (ADC) oversampling engine integrated in microcontrollers belonging to the
STM32 L0 and L4 series.
The main benefit 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.
STM32L0
Microcontrollers
STM32L4
Contents
3 Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4 Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
List of tables
List of figures
'LJLWDORXWSXW
$QDORJ
LQSXW HW
VORSHD
T
W
T
4XDQWL]DWLRQHUURU
T
T
7UDQVIHUIXQFWLRQ
069
2 a ( – q ) ⁄ ( 2a ) 2 q
e(t) = --- ⋅
q ∫ q ⁄ ( 2a )
( e ( t ) ) dt = ----------
12
The theoretical signal-to-noise (SNR) ratio can now be calculated assuming a full-scale
input sine wave is expressed as follows:
s(t) = q × 2(N-1) × sin (2 π f t)
Using the 2 previous equations, we can compute the SNR of an ideal N-bit converter:
SNR = 6.02 × N + 1.76 dB.
It is important to notice that the RMS quantization noise is measured over the full Nyquist
bandwidth (from DC up to Fs / 2).
T
)V
I
%: )V
069
However, under certain conditions where the sampling clock and the signal are harmonically
correlated, the quantization noise becomes correlated, and 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 1.3).
In several applications, the useful signal occupies a bandwidth (BW) smaller than Fs / 2.
If digital filters are used to remove the noise outside BW, the total RMS noise will be reduced
(see Figure 3): the RMS value of the quantization noise will be divided by a ratio which
depends on the useful bandwidth (BW) with respect to the sampling rate (Fs).
T
)V
I
%: )V
069
Then we can reformulate the previous SNR expression by taking into account this
processing gain, by filtering the out-off band noise:
SNR = 6.02 × N + 1.76 dB + 10×Log10 OSR
This expression is valid over a bandwidth of BW, with OSR = Fs / (2 × BW), where OSR is
called the Over Sampling Ratio.
1.3 Dithering
The technique presented above works nicely if the quantization noise is a white one.
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 will not work properly.
This is due to the fact that the quantization noise is no longer random for the first case, and
because in theory there will be no code transitions when the signal is smaller than the
quantization step for the second case.
A way to solve these issues is to use the dithering technique, that consists in adding a small
Gaussian noise to the input signal (see the left part of Figure 4) in order to get a signal (see
the right part of Figure 4) able to insure LSB toggling.
Dithering also insures that the quantization noise will be always a random one,
independently from the input signal.
T
W
T
,QSXWVLJQDO ,QSXWVLJQDO*DXVVLDQQRLVH
069
For sure this noise must be as small as possible in order to avoid important degradation of
the SNR.
The impact of SNR can be strongly reduced if the noise is shaped: for example, we can
imagine that dithering noise is filtered in the wanted BW, and is only present out-off the
wanted BW.
The embedded DAC can be used for generating the dithering signal.
If the application does not require the capture of signal smaller than the quantization step
and if the quantization error can be considered as wideband noise, the dithering technique
can be omitted. This is the case of the 12-bit SAR ADC embedded on STM32L0 and
STM32L4 devices.
0DJQLWXGHG%
)UHTXHQF\N+]
069
Even if not a perfect low-pass filter, it has an interesting property, i.e. the very high
attenuation of the sampling frequency. Then, it’s effective in canceling the out of band noise
resulting in increased signal to noise ratio.
2.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 2.
The HW 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.
3 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
microcontrollers of the STM32 L0 and L4 series.
The cornerstones of the oversampling technique are:
• the RMS quantization noise of an ADC is q / √(12), over the Nyquist bandwidth;
• if the wanted bandwidth is smaller than the Nyquist bandwidth, by using a filter to
remove the out off band noise, the quantization noise is reduced in proportion;
• 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 associated with a software
implementation, resulting in lowering the overall power consumption.
4 Revision history
STMicroelectronics NV and its subsidiaries (“ST”) reserve the right to make changes, corrections, enhancements, modifications, and
improvements to ST products and/or to this document at any time without notice. Purchasers should obtain the latest relevant information on
ST products before placing orders. ST products are sold pursuant to ST’s terms and conditions of sale in place at the time of order
acknowledgement.
Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or
the design of Purchasers’ products.
Resale of ST products with provisions different from the information set forth herein shall void any warranty granted by ST for such product.
ST and the ST logo are trademarks of ST. All other product or service names are the property of their respective owners.
Information in this document supersedes and replaces information previously supplied in any prior versions of this document.