2021-02-11 06:42 AM
I am trying to set up my NUCLEO-G474RE board to perform ADC regular scanning mode using DMA with 4 channels and also discontinuous injection with 2 channels as shown below.
But when I run my code the injected channels always return zero or one, even if I connect their channel to 3.3V. It seems to be sampling the injected channels but for some reason instead of being connected to the actual pins their are tied low internally.
I’ve use STM32CUBEMX to set up my NUCLEO-G474RE board as follows.
I then hit the “GENERATE CODED�? button and make the following code changes to main.c
/* USER CODE BEGIN 0 */
volatile int16_t ADCxConvertedDataAdc[4];
/* USER CODE END 0 */
:
:
/* USER CODE BEGIN 2 */
HAL_ADCEx_Calibration_Start(&hadc1, ADC_SINGLE_ENDED);
HAL_ADCEx_InjectedStart_IT(&hadc1);
HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADCxConvertedDataAdc, 4);
HAL_TIM_PWM_Start_IT(&htim2, TIM_CHANNEL_1);
/* USER CODE END 2 *
If I comment out “HAL_ADC_Start_DMA�? I can see my inject channels sampling random values every second as configured from TIM2.
But when I run with “HAL_ADC_Start_DMA�? I can see the 4 random values being continuous being sampled, but now my injected values only report zero, or sometimes ones.
I've include my ioc and source code as well as a zip file.
Hopefully I'm just doping something stupid in my code to initialise the ADC and it's not a bug in the ADC module.
cheers
Chris
2021-04-14 08:46 AM
Hi CHossack (Community Member) ,
This is limitation of STM32G4 ADC in Rev Y only (your chip has Rev Y). See please STM32G4 devices erratasheets for workaround (chapter: "2.7.8 ADC channel 0 converted instead of the required ADC channel").
In STM32G4 Rev X is this limitation removed.
Regards
Igor
2021-04-16 07:48 AM
hi Igor,
thank you for your help.
cheers
Chris