Bug in ADC initialisation code (CubeIDE / FW_L1)
I found this issue whilst troubleshooting a couple of other issues - device target is STM32L152REx using low-level (LL) libraries.
CubeIDE Version: 1.9.0
CubeMX Version: 6.5.0-RC4
STM32Cube_FW_L1_V1.10.3
If I use lots of ADC channels (22 in my case) the generated code is wrong and the ADC does not function correctly;
CubeMX generates:
ADC_REG_InitStruct.SequencerLength = 22;
Which does not work (22 needs to be shifted left to the correct location in the register), it should generate:
ADC_REG_InitStruct.SequencerLength = LL_ADC_REG_SEQ_SCAN_ENABLE_22RANKS;
Which I had to create my own defines for:
#define LL_ADC_REG_SEQ_SCAN_ENABLE_17RANKS (ADC_SQR1_L_4)
#define LL_ADC_REG_SEQ_SCAN_ENABLE_18RANKS (ADC_SQR1_L_4 | ADC_SQR1_L_0)
#define LL_ADC_REG_SEQ_SCAN_ENABLE_19RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_1 )
#define LL_ADC_REG_SEQ_SCAN_ENABLE_20RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_1 | ADC_SQR1_L_0)
#define LL_ADC_REG_SEQ_SCAN_ENABLE_21RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_2 )
#define LL_ADC_REG_SEQ_SCAN_ENABLE_22RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_2 | ADC_SQR1_L_0)
#define LL_ADC_REG_SEQ_SCAN_ENABLE_23RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_2 | ADC_SQR1_L_1 )
#define LL_ADC_REG_SEQ_SCAN_ENABLE_24RANKS ( ADC_SQR1_L_4 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0)I hope this is useful to someone.
