cancel
Showing results for 
Search instead for 
Did you mean: 

STM32l4 FW 1.10 ADC Rank assert

Miha Mohor?i?
Associate II
Posted on November 15, 2017 at 10:57

Hi,

I have ADC set like so (Code generated by CubeMX):

 sConfig.Channel = ADC_CHANNEL_1;
 sConfig.Rank = 1;
 sConfig.SamplingTime = ADC_SAMPLETIME_2CYCLES_5;
 sConfig.SingleDiff = ADC_SINGLE_ENDED;
 sConfig.OffsetNumber = ADC_OFFSET_NONE;
 sConfig.Offset = 0;�?�?�?�?�?�?�?�?�?�?�?�?

However this fails in stm32l4xx_hal_adc.c file in function:

HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig)�?�?

Specifically assert on

assert_param(IS_ADC_REGULAR_RANK(sConfig->Rank));�?�?�?�?

I assume generated code should look like this:

 sConfig.Rank = ADC_REGULAR_RANK_1;�?�?

Is this correct or am i missing something about this part of code?
1 ACCEPTED SOLUTION

Accepted Solutions
Jeanne Joly
Senior III
Posted on March 05, 2018 at 14:31

Hello

Mohor_i_.Miha

and

Kramer.David

,

This bug is fixed in the current CubeMX release (4.24).

Please upgrade your CubeMX release with the latest one if not already done.

BR. Jeanne

View solution in original post

4 REPLIES 4
Kramer.David
Associate
Posted on November 16, 2017 at 20:14

This seems to be a bug introduced in the L4 1.10 Cube library.

Previously, eachADC_REGULAR_RANK was defined like this:

#define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001) /*!< ADC regular conversion rank 1 */�?

so it was fine that the generated code was

sConfig.Rank = 1;

But now is defined like this:

#define ADC_REGULAR_RANK_1 (LL_ADC_REG_RANK_1) /*!< ADC group regular sequencer rank 1 */�?

with

LL_ADC_REG_RANK_1 as

#define LL_ADC_REG_RANK_1 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS)
...
#define ADC_SQR1_REGOFFSET (0x00000000U)
...
#define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 6U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ1) */�?�?�?�?�?

Your fix will work...until you regenerate the code with STM32CubeMX. It is really something that ST should fix.

Posted on November 16, 2017 at 20:32

Thank you for confirming my problem. 

I should have compared code with earlier releases of FW before posting questions.

I know they have lots of MCUs to test for each FW release, but i do hope STM manages to reduce number of new bugs in FW updates... 

Imen.D
ST Employee
Posted on November 20, 2017 at 11:23

Hello,

Thanks for report this issue. I raised this internally to CubeMx team to be fix in the coming release.

Best Regards

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen
Jeanne Joly
Senior III
Posted on March 05, 2018 at 14:31

Hello

Mohor_i_.Miha

and

Kramer.David

,

This bug is fixed in the current CubeMX release (4.24).

Please upgrade your CubeMX release with the latest one if not already done.

BR. Jeanne