AnsweredAssumed Answered

CubeMX generates wrong ADC code for F0 family when using Vrefint or Temperature channels

Question asked by matveev.maxim on Feb 8, 2015
Latest reply on Feb 16, 2015 by STM32Cube-T


Steps to reproduce:

1) Create new project, select STM32F030C8Tx chip
2) In Peripherials enable Vrefint Channel for ADC
3) Click Configuration -> ADC, optionally configure ADC parameters, note that in the channel config Rank is preset to 1 and cannot be changed
4) Generate code

Following code will be generated to configure channel:
    /**Configure for the selected ADC regular channel to be converted. 
  sConfig.Channel = ADC_CHANNEL_VREFINT;
  sConfig.Rank = 1;
  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
  HAL_ADC_ConfigChannel(&hadc, &sConfig);

It will fail IS_ADC_RANK assert in HAL_ADC_ConfigChannel because provided Rank value is 1, and macro accepts only ADC_RANK_NONE or ADC_RANK_CHANNEL_NUMBER values:

                               ((WATCHDOG) == ADC_RANK_NONE)