2024-07-04 05:21 AM
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
2024-07-08 03:15 AM
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.
2024-07-09 12:19 AM
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.
Thanks
Mathan
2024-07-09 12:58 AM
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...
2024-07-12 12:23 AM
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.
Thanks
Mathan
2024-07-12 12:50 AM
Hello @Mathan Raja,
Did you add ADC2 IN17 conversion as below? And generating project with CubeMx, did a warning message is displayed?