Skip to main content
Graduate II
October 12, 2023
Solved

STM32H723 ADC Oversampling code generation bug

  • October 12, 2023
  • 2 replies
  • 2121 views

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

    This topic has been closed for replies.
    Best answer by KDJEM.1

    Hello @heveskar ,

    The issue is fixed in STM32CubeMX 6.11.0.

    Thank you for your contribution in STCommunity.

    Kaouthar

    2 replies

    Technical Moderator
    October 12, 2023

    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

    KDJEM.1Answer
    Technical Moderator
    March 22, 2024

    Hello @heveskar ,

    The issue is fixed in STM32CubeMX 6.11.0.

    Thank you for your contribution in STCommunity.

    Kaouthar