AnsweredAssumed Answered

Bug report Stm32cubeMX ADC initialization code( Cube v4.6.0/stm32f1xx_hal_adc.c(v1.0.0)

Question asked by forslund.christer on Mar 17, 2015
Latest reply on Mar 18, 2015 by STM32Cube-T
Hi,

I'm quite new to Stm32 development and tried cube for the first time last weekend,

I'm using the STM32VLDISCOVERY board, (which by the way was not in the available list of predefined boards in Cube)  (but selecting the MCU STM32F100RBTx it works)

But, the bug that I found was when I tried to enable ScanConvMode to receive values from several ADC channels. But only the first (rank1) channel got converted.. 

And the reason to this was the mismatch between Cube generated ADC initialization value for enabling ScanConvMode, and the expected value in the driver..

in the Cube generated adc.h

  hadc1.Init.ScanConvMode = ENABLE;

But in the driver it' expects the value ADC_SCAN_ENABLE

in HAL_ADC_Init:

    if (hadc->Init.ScanConvMode == ADC_SCAN_ENABLE)
    {
      tmp_sqr1 = ADC_SQR1_L_SHIFT(hadc->Init.NbrOfConversion);
    }

And since ADC_SCAN_ENABLE  != ENABLE 

The number of conversions is never read, and thus only the first channel in converted..

Since it was the first time trying stm32 it took me half a weekend to realize that the fault was not in my code but in the generated.. =(

/Christer


Edit:  Duplicate Bug Report

Outcomes