Skip to main content
Associate
April 30, 2024
Solved

STM32CubeIDE 1.15.1 (Linux) : Wrong ADC3 Oversampling Ration selection for STM32H743 in .IOC

  • April 30, 2024
  • 2 replies
  • 5017 views

Wrong ADC3 Oversampling Ration selection for STM32H743. It is for STM32H72xx and STM32H73xx, it should a numeric value from 1 to 1024 (RM0433 page 1014). 

The generated code will generate an compilation error : 

'ADC3_OVERSAMPLING_RATIO_2' undeclared (first use in this function); did you mean 'IS_ADC_OVERSAMPLING_RATIO'?ADC3.png

#if defined(ADC_VER_V5_V90)
/** @defgroup ADC_HAL_EC_OVS_RATIO Oversampling - Ratio
 * @{
 */
#define ADC3_OVERSAMPLING_RATIO_2 (LL_ADC_OVS_RATIO_2) /*!< ADC oversampling ratio of 2 (2 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_4 (LL_ADC_OVS_RATIO_4) /*!< ADC oversampling ratio of 4 (4 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_8 (LL_ADC_OVS_RATIO_8) /*!< ADC oversampling ratio of 8 (8 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_16 (LL_ADC_OVS_RATIO_16) /*!< ADC oversampling ratio of 16 (16 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_32 (LL_ADC_OVS_RATIO_32) /*!< ADC oversampling ratio of 32 (32 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_64 (LL_ADC_OVS_RATIO_64) /*!< ADC oversampling ratio of 64 (64 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_128 (LL_ADC_OVS_RATIO_128) /*!< ADC oversampling ratio of 128 (128 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_256 (LL_ADC_OVS_RATIO_256) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_512 (LL_ADC_OVS_RATIO_512) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
#define ADC3_OVERSAMPLING_RATIO_1024 (LL_ADC_OVS_RATIO_1024) /*!< ADC oversampling ratio of 256 (256 ADC conversions are performed, sum of these conversions data is computed to result as the ADC oversampling conversion data (before potential shift). Applicable for ADC3 on devices STM32H72xx and STM32H73xx */
/**
 * @}
 */
#endif

 

    This topic has been closed for replies.
    Best answer by mƎALLEm

    Hello,

    Thank you for the sharing.

    I reproduced the behavior with V6.11.1.

    The internal ticket 180548 (not accessible by community users) has been opened to confirm and fix the issue.

     

    2 replies

    mƎALLEm
    ST Technical Moderator
    April 30, 2024

    Hello,

    Not sure I understood the issue.

    Could you please share the generated code for ADC3?

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    gb1Author
    Associate
    April 30, 2024

    Hello,

     

    hadc3.Instance = ADC3;
     hadc3.Init.Resolution = ADC_RESOLUTION_16B;
     hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
     hadc3.Init.EOCSelection = ADC_EOC_SEQ_CONV;
     hadc3.Init.LowPowerAutoWait = DISABLE;
     hadc3.Init.ContinuousConvMode = ENABLE;
     hadc3.Init.NbrOfConversion = 1;
     hadc3.Init.DiscontinuousConvMode = DISABLE;
     hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
     hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
     hadc3.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DMA_ONESHOT;
     hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
     hadc3.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
     hadc3.Init.OversamplingMode = ENABLE;
     hadc3.Init.Oversampling.Ratio = ADC3_OVERSAMPLING_RATIO_2;
     hadc3.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_NONE;
     hadc3.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
     hadc3.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;
     if (HAL_ADC_Init(&hadc3) != HAL_OK)

     

    Screenshot_2024-05-01_00-10-58.png

     

    stm32h7xx_hal_adc.h

    Code is greyed out because it is not for STM32H743. IOC uses the defines. 

    Screenshot_2024-05-01_00-13-19.png

     

    mƎALLEm
    ST Technical Moderator
    May 2, 2024

    Hello,

    I tested the code generation with CubeMx with version 6.11.0 on Windows and didn't reproduce the issue:

    Here is the generated code:

     hadc3.Instance = ADC3;
     hadc3.Init.Resolution = ADC_RESOLUTION_16B;
     hadc3.Init.ScanConvMode = ADC_SCAN_DISABLE;
     hadc3.Init.EOCSelection = ADC_EOC_SINGLE_CONV;
     hadc3.Init.LowPowerAutoWait = DISABLE;
     hadc3.Init.ContinuousConvMode = DISABLE;
     hadc3.Init.NbrOfConversion = 1;
     hadc3.Init.DiscontinuousConvMode = DISABLE;
     hadc3.Init.ExternalTrigConv = ADC_SOFTWARE_START;
     hadc3.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;
     hadc3.Init.ConversionDataManagement = ADC_CONVERSIONDATA_DR;
     hadc3.Init.Overrun = ADC_OVR_DATA_PRESERVED;
     hadc3.Init.LeftBitShift = ADC_LEFTBITSHIFT_NONE;
     hadc3.Init.OversamplingMode = ENABLE;
     hadc3.Init.Oversampling.Ratio = 2;
     hadc3.Init.Oversampling.RightBitShift = ADC_RIGHTBITSHIFT_NONE;
     hadc3.Init.Oversampling.TriggeredMode = ADC_TRIGGEREDMODE_SINGLE_TRIGGER;
     hadc3.Init.Oversampling.OversamplingStopReset = ADC_REGOVERSAMPLING_CONTINUED_MODE;

    Here, hadc3.Init.Oversampling.Ratio = 2 and not ADC3_OVERSAMPLING_RATIO_2!

    I don't know if it's related to the CubeMx linux version or not but could you please share your ioc file?

    What CubeMx version are you using?

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    mƎALLEm
    mƎALLEmBest answer
    ST Technical Moderator
    May 2, 2024

    Hello,

    Thank you for the sharing.

    I reproduced the behavior with V6.11.1.

    The internal ticket 180548 (not accessible by community users) has been opened to confirm and fix the issue.

     

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.
    gvenkatr13
    Associate
    May 15, 2024

    Similar problem to me after the latest update. Even though I'm not using ADC3. Code generator automatically assigning ADC3_OVERSAMPLING_RATIO_64 when selected oversampling for ADC1 on my STM32H747 project. I'm replacing it everytime with the numerical value.

     

    gvenkatr13_0-1715750101240.png

     

    mƎALLEm
    ST Technical Moderator
    May 15, 2024

    Yes.. It will be fixed in coming revisions of CubeMx.

    To give better visibility on the answered topics, please click "Best answer" on the reply which solved your issue or answered your question.