Skip to main content
one V
Associate III
September 24, 2020
Question

Can the ADC regular channel and injected channel of STM32G4 not be used at the same time? Is this a bug?

  • September 24, 2020
  • 2 replies
  • 2807 views

 I use cubemx (6.0.0) to generate ADC1 configuration code, for example, ADC1 channels 1, 2, and 3 are injection channels, and TIM1 channel 4 is used to trigger, and ADC1’s 4, 5 are Regular channel. STM32F4 can work very well. But STM32G4 does not work, the regular channel does not run.

This topic has been closed for replies.

2 replies

TDK
September 24, 2020

Only one conversion can happen at a time. But depending on your triggers, injected channels may be converted during the same sequence as regular channels. For example, this is from the RM:

Auto-injection mode

If the JAUTO bit in the ADC_CFGR register is set, then the channels in the injected group

are automatically converted after the regular group of channels. This can be used to convert

a sequence of up to 20 conversions programmed in the ADC_SQRy and ADC_JSQR

registers.

"If you feel a post has answered your question, please click ""Accept as Solution""."
one V
one VAuthor
Associate III
September 24, 2020

Thank you very much for your reply. I know the related principles of ADC injection mode and regular channel mode.STM32F4 can work very well. But STM32G4 does not .

Singh.Harjit
Senior
October 6, 2020

Take a look at the errata - maybe you are running into that?

LDoes
Associate II
October 5, 2020

I've got an STM32G474 running both regular and injected channels on all ADCs without any problems. Have you enabled both ADCx->ADSTART and ADCx->JADSTART?

one V
one VAuthor
Associate III
October 9, 2020

This is my ioc file, can you help me see where the configuration is wrong? Or can you generate a keil project and run it?

Thank you very much! 

LDoes
Associate II
October 9, 2020

I can't tell from only the .ioc if all of your code is correct, but some things do stand out. You have set the number of discontinuous conversions to 5 while you only have 2 channels selected in your sequence. Furthermore you have enabled the DMA which slightly complicates things because I can't see how you handle those interrupts.

In your main.c, do you call both HAL_ADC_Start()/HAL_ADC_Start_DMA() and HAL_ADCEx_InjectedStart()/HAL_ADCEx_InjectedStart_IT()?

Can you verify using a debugger that ADC1->DR remains empty?