2015-03-17 05:51 AM
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 valueADC_SCAN_ENABLE
in HAL_ADC_Init: if (hadc->Init.ScanConvMode ==ADC_SCAN_ENABLE
) { tmp_sqr1 = ADC_SQR1_L_SHIFT(hadc->Init.NbrOfConversion); }And sinceADC_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.. =(/ChristerEdit: #adc-scanmode-stm32-stm32f1xx2015-03-17 08:05 AM
Same situation for CubeMXL1
In stm32l1xx_hal.adc.c: if (hadc->Init.ScanConvMode == ADC_SCAN_ENABLE) And in main.c void MX_ADC_Init (void) hadc.Init.ScanConvMode = ENABLE; It's probably worthwhile for ST to check all Cube versions. Regards, Hal2015-03-17 06:29 PM
Upon further investigation:
DISABLE is always defined to be = 0. ENABLE is defined to be !0. ADC_SCAN_ENABLE is defined to be 1. So if ENABLE is set to 1, it can be = ADC_SCAN_ENABLE, and that is the case for MX_ADC_Init. Is your IDE using some other value for ENABLE ? But it is confusing and open to error if two different definitions are used. Cheers, Hal2015-03-18 02:43 AM
Please note this issue will be corrected with MX 4.7.