2019-10-24 11:05 PM
The HAL_ADC_Init() function takes a handle to an Init structure which includes information fields to configure the oversampling feature. The Init.Oversampling.Ratio field is properly applied, but the Init.Oversampling.RightBitShift field is ignored and does not affect the ADC configuration.
It is subsequently necessary to manually change the OVSS bits with the following code after calling the HAL_ADC_Init() function:
ADC1->CFGR2 = (ADC1->CFGR2 & ~ADC_CFGR2_OVSS) | (hadc1.Init.Oversampling.RightBitShift << ADC_CFGR2_OVSS_Pos);