2022-11-04 12:48 PM
The CubeMX correctly allows selection of up to 28 conversions, but generated code fails when set above 16. The libraries sequencer scan length definitions end at LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS and ADC_SQR1_L_4 is not found in the libraries but exists in the STM32L1x programming manual. I should make it clear that I am using the LL (not HAL) drivers. The HAL implementation may work fine.
2022-11-09 07:33 AM
Hi @robd,
Similar issue was already reported in this thread.
As no new version for STM32CubeL1 was released since that period, we expect a fix in coming release of the package.
Internal ticket number: 126534 (This is an internal tracking number and is not accessible or usable by customers).
-Amel
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-06-26 02:18 PM
Well STM32Cube FW_L1 V1.10.4 is here but still has problems with LL code. The LL_ADC_REG_Init() function in library file stm32l1xx_ll_adc.c has some problems.
STM32CubeMX is passing in integer value 26U for the sequencer length when set to make 26 conversions in the STM32CubeMX ADC setup screen. The LL_ADC_REG_Init() function contains assert_param(IS_LL_ADC_REG_SEQ_SCAN_LENGTH(ADC_REG_InitStruct->SequencerLength)); which raises an assert error because 26U is not a valid value. The correct value would be (26U - 1U) << 20U which yields the same as using the defined value LL_ADC_REG_SEQ_SCAN_ENABLE_26RANKS. The library code then proceeds to call LL_ADC_REG_SetSequencerLength(ADCx, ADC_REG_InitStruct->SequencerLength) using the bad value 26U.
The LL_ADC_REG_Init() function further assigns the integer value of 26U to ADC_CR1 which lands it in the AWDCH[4:0] location.
MODIFY_REG(ADCx->CR1,
ADC_CR1_DISCEN
| ADC_CR1_DISCNUM
,
ADC_REG_InitStruct->SequencerLength // CubeMX sets this to 26U when set for 26 conversions
| ADC_REG_InitStruct->SequencerDiscont
);
Having the 26U value here may be by design but I will leave that up to your programmers.
This one is particularly annoying as I log all asserts and I constantly have to take time to check the log that would otherwise be empty if this bug did not exist.