cancel
Showing results for 
Search instead for 
Did you mean: 

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

mail239955_stm1
Associate
Posted on February 08, 2015 at 14:05

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:

#define IS_ADC_RANK(WATCHDOG) (((WATCHDOG) == ADC_RANK_CHANNEL_NUMBER) || \

                               ((WATCHDOG) == ADC_RANK_NONE)             

1 REPLY 1
stm32cube-t
Senior III
Posted on February 16, 2015 at 22:52

Hello,

This will be fixed in 4.7 with:

sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;

Best regards