Skip to main content
FMink.1
Associate
Mar 11, 2021 1:50 PM UTC
Solved

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

This topic has been closed for replies.
Khouloud ZEMMELI
Khouloud ZEMMELIBest answer
ST Employee
Aug 19, 2021 8:54 AM UTC

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

9 replies

Khouloud ZEMMELI
ST Employee
Mar 11, 2021 2:56 PM UTC

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
FMink.1Author
Associate
Mar 11, 2021 8:00 PM UTC

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
Mar 15, 2021 9:35 AM UTC

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

Khouloud ZEMMELI
Khouloud ZEMMELIBest answer
ST Employee
Aug 19, 2021 8:54 AM UTC

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
FMink.1Author
Associate
Nov 22, 2021 2:48 PM UTC

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
FMink.1Author
Associate
Nov 22, 2021 4:18 PM UTC

There are several other Bugs.

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

0693W00000GYTIpQAP.png 

Khouloud ZEMMELI
ST Employee
Nov 22, 2021 4:20 PM UTC

Hello @FMink.1​ 

Could you please share your ioc file?

Thanks, Khouloud

FMink.1
FMink.1Author
Associate
Nov 22, 2021 4:39 PM UTC

sorry, just forgot it. It is attached now

Khouloud ZEMMELI
ST Employee
Nov 25, 2021 8:11 AM UTC

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