cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H723 ADC Oversampling code generation bug

heveskar
Senior

I am using STM32CubeIDE v1.13.2. When setting oversampling for ADC3 on STM32H723, the ratio value is incorrectly generated to exactly the number that is typed in the GUI:

heveskar_0-1697111110765.png

 

 

hadc3.Init.Oversampling.Ratio = 32;

 

which is then on lines 725-735 in stm32h7xx_hal_adc.c written directly to the CFGR2 register:

 

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
);

 

however, for oversampling on ADC3, there is this mapping for the values:
000: 2x
001: 4x
010: 8x
011: 16x
100: 32x
101: 64x
110: 128x
111: 256x

By pure chance, this works correctly for values 2, 4 and 8 (as OVSR is offset by 2 in CFGR2). Higher values are of course broken.

The generated value should probably be from the ADC_HAL_EC_OVS_RATIO. As this is different from ADC1 and ADC2, I think that in Cube GUI, there should be a choice of predefined values and not free text as in ADC1 and ADC2.

Similar to this issue that was fixed: https://community.st.com/t5/stm32-mcus-embedded-software/stm32h745-adc-oversample-bug-in-hal/td-p/583308

1 ACCEPTED SOLUTION

Accepted Solutions
KDJEM.1
ST Employee

Hello @heveskar ,

The issue is fixed in STM32CubeMX 6.11.0.

Thank you for your contribution in STCommunity.

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.

View solution in original post

2 REPLIES 2
KDJEM.1
ST Employee

Hello @heveskar,

I reported the issue 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.

KDJEM.1
ST Employee

Hello @heveskar ,

The issue is fixed in STM32CubeMX 6.11.0.

Thank you for your contribution in STCommunity.

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.