Hot to use EVSPIN32G4 on board potentiometer?
Hi all,
I'm new to the STM32 MCU familiy, so I've got trouble already doing basic stuff like reading the analog input value of the potentiometer. My main problem is, that I don't understand how multiple measurements can be made on one single ADC. I've watched several Videos about the topic already, but can't get it to wok properly. With some code variants I read bigger numbers that shouldn't be possible with a 12bit ADC (23.000-ish or even bigger), with other codes I dont get anything back at all.
What I did so far:
The datasheet states that the potentiometer is connected to pin PC3, so I added this pin in CubeMX as a ADC1_IN9 pin. In the ADC1 Mode and Config tab, I didn't change any settings, as I'm not sure if its needed. Only thing I've read in one of STM's MC docs is that I'm not allowed to use the injected conversion mode as it will interfere with the motor controls.
In the while loop I added these commands:
HAL_ADC_Start(&hadc1);
ADC_ChannelConfTypeDef sConfig = {0};
sConfig.Channel = ADC_CHANNEL_9;
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;
HAL_ADC_ConfigChannel(&hadc1, &sConfig)
HAL_ADC_PollForConversion(&hadc1, 20)
Value = HAL_ADC_GetValue(&hadc1);
What am I missing?
Best regards, Jordan


