The STM32 built-in multi-channel ADC works well when configured right and misreads when not. This page covers the clock, channels, sampling time, calibration and DMA essentials.
Clock and resolution: the ADC clock comes from APB2 through a prescaler with a hard ceiling, about 14MHz on F1, 30MHz on F4 and higher on H7; exceed it and accuracy falls. Resolution is selectable at 6, 8, 10 or 12 bits, slower as it rises, and results can be aligned left or right by range. Multiple channels are queued in the regular group or the injected group.
Sampling time: each channel carries its own sampling time, 1.5 to 239.5 cycles in ADC_SMPR. A high-impedance source, a divider or a sensor, needs a long sampling time so the internal sample capacitor charges fully, or readings sag low. The rule: sampling time times the ADC clock must cover the settling of Rsource with Cin. Too short a time is the number one cause of inaccurate readings on high-impedance signals.
Calibration and DMA: run the power-on calibration, HAL_ADCEx_Calibration_Start, to remove offset; feed Vref from a stable reference or use the internal VREFINT for ratio measurements. For continuous multi-channel work let DMA move results into memory instead of reading one by one in an interrupt. Input voltage must never exceed Vref, overvoltage latches or damages the pin, so clamp the front end.
| Setting | Watch | Consequence |
|---|---|---|
| Clock | Under the ceiling | Accuracy drops |
| Sampling time | Match source impedance | Readings sag low |
| Resolution | Higher is slower | A trade-off |
| Calibration | Run at power-up | Removes offset |
| DMA | Move multi-channel results | Efficiency |
| Overvoltage | Never above Vref | Damage |
Lengthen the sampling time for high-impedance sources, calibrate at power-up, and use DMA for multiple channels. Clamp the front end so inputs never exceed Vref.
The quantities and component characteristics discussed here follow current national standards and the corresponding IEC documents: MCU ADC configuration per GB/T 4728 and IEC 60748 series. Always check the device datasheet and the product design file for ratings and derating.
Locate the issue with the approach above, then confirm with measurements; safety-related circuits must follow the standards and manufacturer requirements.