Skip to main content
Miha Mohor?i?
Associate
November 15, 2017
Solved

STM32l4 FW 1.10 ADC Rank assert

  • November 15, 2017
  • 3 replies
  • 1410 views
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?
    This topic has been closed for replies.
    Best answer by Jeanne Joly
    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

    3 replies

    Kramer.David
    Visitor II
    November 16, 2017
    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.

    Miha Mohor?i?
    Associate
    November 16, 2017
    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... 

    Technical Moderator
    November 20, 2017
    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

    In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks
    Jeanne Joly
    Jeanne JolyBest answer
    Associate
    March 5, 2018
    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