cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L4 ADC oversampling setup

hchoi.1
Associate II

0693W00000SvsRqQAJ.pngI 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

6 REPLIES 6
Imen.D
ST Employee

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

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen

What's the reason for doing the right shift?

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

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?

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

Piranha
Chief II

An oversampling of 128x compared to 8x will take 128/8=16 times longer and will give sqrt(16)=4 times less noise.