2025-02-02 12:09 PM
Hello All,
We have a problem with crosstalk between two neighboring ADC pins. On a STM32L496, on PA7 and PC4, two independent single-ended ADC channels are configured in the most simplified way possible.
Connected pins and ADC config:
Method/Function:
This is the function to read the ADC value.
uint32_t getVoltageADC(ADC_HandleTypeDef *hadc, uint8_t channel) {
// Configure the ADC channel parameters
ADC_ChannelConfTypeDef sConfig = {
.Channel = STM32ADCChannelLookUp[channel],
.SamplingTime = ADC_SAMPLETIME_640CYCLES_5,
.Rank = 1
};
HAL_StatusTypeDef status = HAL_OK; // Initialize status variable to track HAL function success
status |= HAL_ADC_ConfigChannel(hadc, &sConfig); // Configure ADC channel
status |= HAL_ADC_Start(hadc); // Start ADC conversion
status |= HAL_ADC_PollForConversion(hadc, HAL_MAX_DELAY); // Wait for conversion to complete
uint32_t raw = HAL_ADC_GetValue(hadc); // Retrieve raw ADC value
status |= HAL_ADC_Stop(hadc); // Stop ADC operation
assert(status == HAL_OK);
HAL_Delay(5); // Ensure all HAL operations completed successfully
return (uint32_t)raw; // Return the raw ADC value
}
It is called with
ai_throttleRead = getVoltageADC(&hadc1, 12);
The hardware design can be found in the attached image. Throttle (c_throttleRead) is an input from 1-5V, Regen (c_regenRead) is a 10k potentiometer, powered by 3.3V.
Problem:
As long as the potentiometer for the regen is not connected, the throttle works perfectly and has an ADC value of 1500 for 1V (0.64V at pin) and larger values for more throttle. This seem high but I can handle that in the software.
If the regen potentiometer gets connected, the reading for the constant throttle voltage of 1V changes from ADC=2500 if GND is connected and ADC=600 for 3.3V on the regen pin. In other words, changing the voltage at the neighboring pin, changes the ADC reading.
Notes:
Tests:
Hardware
Hardware Chip: STM32L496VGTx
2025-03-18 2:59 AM
Hello,
Did you test with a non-neighboring channels?
2025-03-18 3:05 AM
Have you measured externally at the pins?
2025-03-18 10:05 AM
This is normal, considering 27k /47k divider. To have low transit error buffer ADC inputs using high speed OPA, that can operate at 3.3V and has R2R outputs.