2020-09-24 02:01 AM
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.
2020-09-24 06:06 AM
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.
2020-09-24 07:07 AM
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 .
2020-10-05 05:35 AM
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?
2020-10-05 06:05 PM
Take a look at the errata - maybe you are running into that?
2020-10-08 08:17 PM
2020-10-09 12:37 AM
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?
2020-10-09 01:32 AM
I called the following function: HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_4);HAL_ADCEx_InjectedStart_IT(&hadc1); HAL_ADC_Start_DMA(&hadc1, adc_regular_val, 2); and uint32_t adc_regular_val[2];
2020-10-11 11:16 PM
Hmm, I think that is the correct way to do it.
Can you take a look at the solution in https://community.st.com/s/question/0D50X0000BUlAzpSQF/haladcstartdma-example-always-get-value-0 ?