Vref (voltage reference) is a stable, accurate DC voltage used as a known baseline against which other voltages are measured or converted. In embedded systems it most commonly sets the full-scale input range of an ADC or the full-scale output range of a DAC.
In practice
On most MCUs with an integrated ADC, Vref defines the voltage that corresponds to the maximum digital code. For a 12-bit ADC with Vref = 3.3 V, an input of 3.3 V ideally produces a code of 4095 and an input of 1.65 V produces roughly 2047. Any error or noise on Vref appears directly as a gain error or noise floor in every conversion, so the quality of Vref is a hard ceiling on ADC accuracy from a reference standpoint -- though other sources such as INL, offset, and input impedance independently limit accuracy as well.
Many MCUs supply an internal Vref, typically derived from a bandgap circuit. These internal references are convenient but vary in accuracy: a device like the STM32L4 internal reference is specified at 1.212 V nominal with an initial accuracy of roughly +/-0.4%, while lower-cost parts may specify only +/-1% or worse over temperature. For precision measurements -- current sensing, load cells, 16-bit audio ADCs -- an external dedicated reference IC (such as the ADR4550, REF5050, or LT6657) is usually necessary to achieve better initial accuracy and lower temperature drift (down to single-digit ppm/degC).
Vref noise is a common and subtle pitfall. Switching regulators, digital logic transitions, and even ADC sampling transients can couple noise onto the Vref pin. Decoupling Vref with a low-ESR ceramic capacitor close to the pin (100 nF to 10 uF is a common range) and, where the reference IC supports it, adding a larger bulk capacitor on a noise-filter pin (FILTER or BYP pin) significantly reduces this. Routing Vref traces away from switching nodes and clock lines is equally important.
For DACs, the same principle applies in reverse: Vref sets the full-scale output, so reference drift directly translates to output drift. Ratiometric measurement techniques -- where the sensor excitation voltage and Vref are derived from the same source -- can cancel out supply variations entirely and are worth considering when absolute accuracy matters less than repeatability.
Frequently asked
What happens if my ADC input exceeds Vref?
On most ADCs, an input above Vref saturates the converter at the maximum code and does not damage the part -- provided the input voltage stays within the device's absolute maximum rating for that pin, which is often Vdd + 0.3 V or a specified clamp level. Behavior can vary depending on the
ADC's protection structures, input muxing, and sampling conditions, so always verify against the specific datasheet. Exceeding the absolute maximum can permanently damage the input stage. Always check both the ADC full-scale spec and the pin absolute maximum in the datasheet.
Can I use the supply rail (3.3 V or 5 V) directly as Vref?
You can, and many designs do for non-critical measurements. The drawback is that supply rails typically carry 10-100 mV of ripple and noise from regulators and load transients, which degrades effective
ADC resolution. For an 8- or 10-bit ADC in a coarse control loop this is often acceptable. For 12-bit or higher precision work, a dedicated reference IC or at minimum a well-filtered and decoupled supply tap is preferable.
What is a bandgap reference and why does it appear in MCU datasheets?
A bandgap reference is an analog circuit whose output voltage is derived from the silicon bandgap energy (~1.25 V in silicon), making it relatively stable over temperature.
MCU internal Vref circuits are almost universally bandgap-based. The resulting voltage is scaled and trimmed to a device-specific target value (commonly in the range of 1.2 V to 2.5 V, with values such as 2.048 V also appearing) and its trimmed value is sometimes stored in factory calibration
registers -- as on STM32 parts, where VREFINT_CAL allows software to compensate for part-to-part variation.
What is ratiometric measurement and when does it help?
Ratiometric measurement means powering the sensor from the same voltage used as Vref, so that if the supply drifts, both the sensor output and the
ADC full-scale shift together and the ratio -- the measured value -- stays constant. It is commonly used with resistive bridge sensors (strain gauges, pressure sensors) and potentiometers. It eliminates reference accuracy as an error source but does not help when the sensor has its own internal excitation or when absolute voltage measurement is required.
How do I calculate the LSB size and expected code for a given input voltage?
LSB size = Vref / 2^N, where N is the
ADC resolution in bits. For a 12-bit ADC with Vref = 3.3 V, LSB = 3.3 / 4096 ~= 0.806 mV. Expected code = (Vin / Vref) * (2^N - 1), so 1.0 V in produces roughly (1.0 / 3.3) * 4095 ~= 1241. These are ideal values; offset error, gain error, and nonlinearity from the datasheet spec table describe how real conversions deviate.
Differentiators vs similar concepts
Vref is sometimes confused with Vdd or AVDD (the analog supply pin). AVDD powers the analog circuitry of the
ADC or
DAC and should be clean, but it is not the measurement reference -- it merely keeps the converter's internal circuits operating. Vref specifically sets the conversion span. On some low-cost MCUs or simplified board designs the two are externally shorted or share the same net, which blurs the distinction, but on higher-performance parts (SAR ADCs, sigma-delta converters) they are separate pins with separate specs and decoupling requirements. Vref also differs from a
voltage regulator output: a regulator is designed to supply load current with controlled output impedance, while a reference IC is optimized for initial accuracy, low temperature coefficient, and low noise, typically at very low output currents.