cancel
Showing results for 
Search instead for 
Did you mean: 

ADC Injected Mode LL code generation needs manual workarounds

FMink.1
Associate II

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

1 ACCEPTED SOLUTION

Accepted Solutions

Hello @FMink.1​ ,

I'm back again to inform you that issue is now fixed, you can use the latest CubeMX version available on site :)

Khouloud

View solution in original post

9 REPLIES 9
Khouloud ZEMMELI
ST Employee

Hello @FMink.1​ 

Thanks for your feedback,

Could you please check with the latest Cube version (1.6.0 for IDE and 6.2.0 for MX)?

If you still face a problem please share your ioc file to check your case.

Thanks, Khouloud

FMink.1
Associate II

Dear Khouloud,

thank you for the quick reply. I upgraded to STM32CubeMX 6.2.0.202102191602  and STM32CubeIDE 1.6.0.202101291314 and the generated ADC initialization code is still exactly the same.

the ioc file is attached.

Best regards

Fabian

Khouloud ZEMMELI
ST Employee

Hello @FMink.1​ 

Sorry for the delay, thank you for providing your ioc file which helped me to reproduce issues.

Issues confirmed and they will be fixed, many thanks for raising such a problem to our attention =)

Your contribution is always welcome, Khouloud

Hello @FMink.1​ ,

I'm back again to inform you that issue is now fixed, you can use the latest CubeMX version available on site :)

Khouloud

FMink.1
Associate II

It does not work. E.g., if 2 injected channels are configured, ADC_INJ_InitStruct.SequencerLength = 2 is set from code generation tool.

But it should be ADC_INJ_InitStruct.SequencerLength = LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS

LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS is not equal to 2, but (0x1 << 20)!

I still need workarounds to get the desired behaviour.

Best regards, Fabian

FMink.1
Associate II

There are several other Bugs.

Code as it is generated (left) compared to as it should be (right):

0693W00000GYTIpQAP.png 

Hello @FMink.1​ 

Could you please share your ioc file?

Thanks, Khouloud

FMink.1
Associate II

sorry, just forgot it. It is attached now

Khouloud ZEMMELI
ST Employee

Hi @FMink.1​ ,

The original issue has been fixed (issue raised in the description), this one is newer, and thank you for raising it to our attention, I already analyzed the problem and I confirm the issue, but could you please add new post, so that the issue will be visible to the other Community members which are facing the same problem as you and to be able to put a status on it?

Thanks, Khouloud