What to Do When the External Reference Voltage of the MCU ADC Changes?

This article is the second in a series discussing peripheral modules of microcontrollers, focusing on how to improve ADC conversion accuracy.In this article, I will summarize the understanding of the reference voltage for ADCs, which many engineers are not very clear about, especially in scenarios where the ADC is used with a battery directly powering the MCU.

Taking the classic STM32F103 as an example, the reference voltage for the ADC is input through the external pins VREF+/VREF-. For some models with 64 pins or fewer, VREF+ is internally connected to the VDDA signal line and is not brought out to the outside; in this case, the ADC reference voltage is VDDA.

What to Do When the External Reference Voltage of the MCU ADC Changes?

When the ADC reference voltage is stable and unchanged, normal data collection and calculations can proceed. However, when the reference voltage changes, if the previous reference voltage is still used, it will lead to measurement errors due to the inability to directly obtain the new reference voltage value.

What should be done in this case? The internal reference voltage VREFINT of the chip can be utilized, which is a relatively fixed voltage with a typical value of 1.20V.

What to Do When the External Reference Voltage of the MCU ADC Changes?

It is internally connected to ADC channel 17. If the accuracy requirement for ADC measurements is not very high, VREFINT can be considered as a fixed 1.2V. At this point, by reading the value of this channel REFINT_DATA, the current ADC reference voltage can be deduced. Because 1.2V = VREF_ADC * REFINT_DATA / FULL_SCALE

Thus, VREF_ADC = 1.2V * FULL_SCALE / REFINT_DATA, where FULL_SCALE is 4095 (ADC resolution 12 bits).

Using the deduced reference voltage value, the actual ADC measurement value can be calculated.

Vchx = VREF_ADC * ADCHX_DATA / FULL_SCALE = 1.2V * (ADCHX_DATA / REFINT_DATA).

However, in practice, there will be differences in VREFINT between individual chips. If higher accuracy is required, calibration methods can be employed:

When VDDA is stable at 3.3V, the value of the VREFINT channel can be collected through the ADC, denoted as REFINT_CAL. This allows for obtaining the accurate VREFINT voltage for each chip. In actual use, REFINT_CAL needs to be stored in the MCU Flash for later use. Then, the ADC measurement value can be calculated according to the aforementioned method (i.e., first reading ADC channel 17 to deduce the current actual reference voltage, then reading the actual channel value to calculate the ADC measurement value).

Vchx = (3.3V * REFINT_CAL / FULL_SCALE) * (ADCHX_DATA / REFINT_DATA).

This method increases the workload for users, as the STM32F103 is an older product that does not have factory calibration. Newer products like the STM32F030 have already undergone the aforementioned calibration at the factory, allowing users to use them directly.

What to Do When the External Reference Voltage of the MCU ADC Changes?

At this point, you may be curious about what this internal reference voltage is; it is known as the Bandgap voltage. The MCU’s Bandgap voltage is a highly stable voltage reference source, typically generated by the Bandgap Reference Circuit within the integrated circuit. The Bandgap circuit utilizes the positive and negative temperature coefficients of bipolar transistors to cancel each other out, generating a voltage that is almost unaffected by temperature changes (with a typical value of about 1.2V, though the exact value varies with process and design).

Having said all this, the internal Bandgap voltage is not the direct reference voltage source for the ADC. It is merely used to deduce the actual reference voltage value. This method has certain limitations, as it requires the ADC to first sample the Bandgap channel voltage and then sample the actual channel voltage. If there is a sudden change in the reference voltage during this sampling process, the converted value will also be inaccurate because the deduced reference voltage has changed. However, the likelihood of this situation occurring is relatively low, and for most scenarios, this method works fine.

Some MCUs have an internal voltage reference source, such as the STM32L5, which is called VREFBUF.

It can support two voltages, 2.048V and 2.5V, which can be used directly as the ADC reference voltage.

The reference source still comes from the Bandgap voltage, generating different output levels through a voltage divider circuit. As shown in the block diagram below, due to the virtual short characteristics of the operational amplifier, the negative input of the operational amplifier is equal to the voltage of the positive input (Bandgap reference voltage). The voltage divider resistors on the right adjust the division ratio to set the output voltage of VREFBUF. When using this function, be aware that the Vref+ pin must be occupied and connected to a capacitor to ground; otherwise, this reference voltage cannot be generated.

What to Do When the External Reference Voltage of the MCU ADC Changes?

The deviation of VREFBUF is relatively small, as described in the manual:

What to Do When the External Reference Voltage of the MCU ADC Changes?

Using VREFBUF is much more convenient; you only need to sample the required channel. It is important to note that the sampled voltage value must not exceed the VREFBUF voltage value. For example, if the sampled voltage value is 3V, a voltage divider must be used before sampling.

Of course, if the external reference voltage for the ADC in the system is already very stable, none of the above introductions are necessary.

What to Do When the External Reference Voltage of the MCU ADC Changes?

END

Source:TopSemic Embedded

Copyright belongs to the original author. If there is any infringement, please contact for deletion..Recommended ReadingOverview of Job Positions and Salary Status at ZhiHuiJun CompanyA Guide to Writing Embedded Driver Programs (Based on Timing Diagrams)Why is Hardware More Difficult than Software, Yet Hardware Engineers Earn Less?→ Follow for More Updates ←

Leave a Comment