ADC Channel Conversion Difference
Guys, I need help with ADC on STM32F407ZGTx. I have a project where I read 2 channels, ADC3_IN4 and ADC3_IN15. Since I need a function that has pin ADC3_IN15, I changed it to ADC3_IN8.
The problem is that I don't know what it is about STM32F407ZGTx, at least mine, that makes a difference in the reading.
On IN15, I had ranges from 54 to 920 in the final read value (this is the correct range).
However, on IN8, reading the same voltage levels, it is reading from 64 to 706. In addition to giving me incorrect ranges (for example, in the middle of the reading, it should give me 313, but it is giving me 460, which is the value that I read with IN15 and which is correct).
Are there any differences in the inputs? I've looked in several places, the STM32F407ZGTx manual, AN's, etc., and nothing, no one says anything. I tried DMA, nothing either. If I go back to IN15, the reading becomes constant and correct again.
Attached is an image of the configuration on the STM32CUBEIDE
.
PS: I checked the values read by debug in each channel(IN15 and IN8), and they are really like that, analyzing the same voltage levels, but returning different values.
Below is the code that I read from the channels ADC
int analogRead(uint16_t GPIO_Pin)
{
int vAnalogData;
ADC_ChannelConfTypeDef sConfig = {0};
switch (GPIO_Pin)
{
case 10:
sConfig.Channel = ADC_CHANNEL_8;
break;
case 6:
sConfig.Channel = ADC_CHANNEL_4;
break;
}
sConfig.Rank = 1;
sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
HAL_ADC_ConfigChannel(&hadc3, &sConfig);
HAL_ADC_Start(&hadc3);
HAL_ADC_PollForConversion(&hadc3, 1000);
vAnalogData = HAL_ADC_GetValue(&hadc3);
HAL_ADC_Stop(&hadc3);
sConfig.Rank = 0;
sConfig.SamplingTime = ADC_SAMPLETIME_84CYCLES;
HAL_ADC_ConfigChannel(&hadc3, &sConfig);
return vAnalogData;
}
