2022-09-21 12:46 AM
I want to use the adc 15bit resolution.
I don't understand why right shift and oversampling ratio are at the same time.
1. what is difference
12bit + 4bit right shift + oversampling ratio 128x
and
12bit + oversampling ratio 8x?
2. What are the functions and roles?
Please give me a detailed answer that is easy to understand
2022-09-21 02:18 AM
Hello @hchoi.1 and welcome to the Community :)
You find details in AN4629 Application note "ADC hardware oversampling for microcontrollers of the STM32 L0 and L4 series". This application note 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.
According to this training STM32L4-ADC, the oversampler can accommodate from 2 to 256 times samples and right shift from one to eight binary digits.
You can also get inspired from the working example from STM32L4 MCU package (using with LL driver):
\STM32Cube_FW_L4_V1.17.2\Projects\NUCLEO-L476RG\Examples_LL\ADC\ADC_Oversampling\
Imen
2022-09-21 07:18 PM
What's the reason for doing the right shift?
2022-09-22 03:16 AM
If you oversample by 2^N (N=7 in case of oversampling by 128) the 12-bit ADC result is added 2^N times, resulting in 12+N-bit number (in case of N=7 it's 19 bits). The ADC data register is only 16-bit, so if the mcu wouldn't right-shift before moving the result from the 20-bit internal accumulator into ADC data register, the uppermost bits (19-16=3 in case of N=7) would get lost.
JW
2022-09-22 09:31 PM
thanks for your answer JW
i understood your comment.
so then, what is difference 12bit + 4bit right shift + oversampling ratio 128x and 12bit + oversampling ratio 8x?
Both are equal to 15 bits ADC.
noise? anti-aliasing? or what?
2022-09-22 11:50 PM
Your measurement will take 128x longer but you'll have cca 11x less noise.
[EDIT] see Piranha's post below - indeed, I compared it to single conversion which wouldn't return 15 bits, so it's an incorrect comparison[/EDIT]
https://en.wikipedia.org/wiki/Oversampling#Resolution
JW
2022-09-28 02:46 PM
An oversampling of 128x compared to 8x will take 128/8=16 times longer and will give sqrt(16)=4 times less noise.