ADC Injected Mode LL code generation needs manual workarounds
I am using cubeIDE 1.5.0 with STM32F103RBT
I configured 2 injected channels, triggered by Tim1 trigger out event in the device configuration tool. After that
- code generation for Initializing ADC injected group (call to function LL_ADC_INJ_Init) is completely missing and
- Sequencer Rank configuration contains calls function LL_ADC_INJ_SetSequencerRanks with LL_ADC_REG_RANK_x instead of LL_ADC_INJ_RANK_x
Workaround (added to USER CODE BEGIN ADC1_Init 2):
//Cube IDE does not generate code for ADC INJ Mode initialization.
//SequencerLength setting must be done !!BEFORE!! LL_ADC_INJ_SetSequencerRanks
LL_ADC_INJ_InitTypeDef init_inj;
LL_ADC_INJ_StructInit(&init_inj);
init_inj.SequencerLength = LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS;
init_inj.TriggerSource = LL_ADC_INJ_TRIG_EXT_TIM1_TRGO;
init_inj.TrigAuto = LL_ADC_INJ_TRIG_INDEPENDENT;
init_inj.SequencerDiscont = LL_ADC_INJ_SEQ_DISCONT_DISABLE;
LL_ADC_INJ_Init(ADC1,&init_inj);
//Re-initialize Sequencer Ranks correctly
LL_ADC_INJ_SetSequencerRanks(ADC1, LL_ADC_INJ_RANK_1, LL_ADC_CHANNEL_1);
LL_ADC_INJ_SetSequencerRanks(ADC1, LL_ADC_INJ_RANK_2, LL_ADC_CHANNEL_8);
now, ADC injected channels work as expected, but it seems to me that these are bugs in the configuration tool that should be fixed