cancel
Showing results for 
Search instead for 
Did you mean: 

Bug in HAL_ADC_Init when using oversampling on ADC3, CPU is H723

QLiu.6
Associate II

3.jpg

Set ADC3 with 16 oversampling

4.jpg

But what I got is doubled. ADC3[1] is 5V and ADC3[4] is 3.3V

-------------------------------------

In "void MX_ADC3_Init(void)",

hadc3.Init.Oversampling.Ratio = 16;
hadc3.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_4;

Went through the HAL_ADC_Init(), found

#if defined(ADC_VER_V5_V90)
if (hadc->Instance == ADC3)
{
/* Configuration of Oversampler: */
/* - Oversampling Ratio */
/* - Right bit shift */
/* - Triggered mode */
/* - Oversampling mode (continued/resumed) */
MODIFY_REG(hadc->Instance->CFGR2,
ADC_CFGR2_OVSR |
ADC_CFGR2_OVSS |
ADC_CFGR2_TROVS |
ADC_CFGR2_ROVSM,
ADC_CFGR2_ROVSE |
hadc->Init.Oversampling.Ratio |
hadc->Init.Oversampling.RightBitShift |
hadc->Init.Oversampling.TriggeredMode |
hadc->Init.Oversampling.OversamplingStopReset
);
}
else
{

When "Ratio" is 16, it's directly written into "CFGR2" with other settings. This is not right. It's actually making a 32x oversampling.

Change the setting as "0x0C", I got what I want.

5.jpg

1 REPLY 1
KDJEM.1
ST Employee

Hello @QLiu.6 ,

Thank you for bringing this issue to our attention.

I reported this bug internally.

Internal ticket number: 163742 (This is an internal tracking number and is not accessible or usable by customers).

Thank you.

Kaouthar

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.