cancel
Showing results for 
Search instead for 
Did you mean: 

EVSPIN32G4 ADC not working

Mathan Raja
Associate III

Hi, Good Morning

            I want to control the motor through an analog input (PA4) (ADC2_IN17). However, I am unable to read the ADC value. The generated code lacks the initial configuration for ADC2 channel 17 in the MX_ADC2_Init() function.

Please advise on how to call and read the value.

I have attached the code, which works fine with the STM32H573 eval board.

Thanks

Mathan

5 REPLIES 5
GMA
ST Employee

Hello @Mathan Raja,

On your attached main.c file, there is no ADC2 init...

I assume that you are using a customized board, isn't it? What is the purpose of this ADC2 IN17 input?

Did code generate without errors? Once code generated, you can launch CubeMX tool in order to check your ADC2 configuration. 

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

Hi GMA,

I have attached the code for the STM32H573 eval board.

I use the EVSPIN32G4 eval board to control the motor with an analog voltage through the PA4 pin, corresponding to ADC2 channel 17. Despite enabling ADC2 IN17 in CubeMX, the generated code does not include initialization for ADC2 channel 17.

MathanRaja_0-1720509113880.png

Thanks

Mathan

GMA
ST Employee

Hello @Mathan Raja,

I generated an EVSPIN32G4 from scratch with MCSDK6.3, opening .ioc file with CubeMx, I went to ADC2 Tab, select "IN17 Single-ended", go to "ADC2 parameter settings", add this new conversion on ADC_Regular_ConversionMode field for example, and generated code with CubeMx. On main.c file, I have the ADC2 IN17 initialization...

 

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA

 

Hi GMA,

In my case, the ADC initialization is occurring.

MX_ADC1_Init(void);

MX_ADC2_Init(void);

 

However, I do not see a configuration for ADC2 channel 17 within that initialization. Like below

  /** Configure Regular Channel

  */

  sConfig.Channel = ADC_CHANNEL_5;

  sConfig.Rank = ADC_REGULAR_RANK_1;

  sConfig.SamplingTime = ADC_SAMPLETIME_47CYCLES_5;

  sConfig.SingleDiff = ADC_SINGLE_ENDED;

  sConfig.OffsetNumber = ADC_OFFSET_NONE;

  sConfig.Offset = 0;

  if (HAL_ADC_ConfigChannel(&hadc2, &sConfig) != HAL_OK)

  {

    Error_Handler();

  }

 

The Motor Control Workbench project was developed using STM32CubeMX version 6.9.2 and MCSDK version 6.2.0. However, attempting to migrate to MCSDK version 6.3.0 results in encountered errors.

attr not supported : dmpu

I have reverted to the original version developed with MCSDK 6.2.0 and STM32CubeMX 6.9.2. However, I am now facing errors with this version as well.

MathanRaja_1-1720768956694.png

Thanks

Mathan

 

GMA
ST Employee

Hello @Mathan Raja,

Did you add ADC2 IN17 conversion as below? And generating project with CubeMx, did a warning message is displayed?

GMA_0-1720770148864.png

 

If you agree with the answer, please accept it by clicking on 'Accept as solution'.
Best regards.
GMA