Electronic – ATMega328 External AREF Connection


From the ATMega328 datasheet, section 24.9.1:

The internal voltage reference options may not be used if an external
reference voltage is being applied to the AREF pin.

From the Arduino reference pages:

Alternatively, you can connect the external reference voltage to the
AREF pin through a 5K resistor, allowing you to switch between
external and internal reference voltages. Note that the resistor will
alter the voltage that gets used as the reference because there is an
internal 32K resistor on the AREF pin. The two act as a voltage
divider, so, for example, 2.5V applied through the resistor will yield
2.5 * 32 / (32 + 5) = ~2.2V at the AREF pin.

The ATMega328 datasheet confirms the "internal 32k resistor" reference in table 29.16 ADC Characteristics with: Reference Input Resistance = 32 kOhm.

That being said, the above two statements seem to be somewhat in opposition to one another. I've got an application with some sensors outputting 0-5V full scale and others outputting 0-1.8V full scale. The application would benefit from the increased resolution of switching to 1.8V AREF when sampling the 1.8V sensors and switching to the internal AVCC reference for the 5V sensors.

The Arduino reference pages suggest that's an OK thing to do given you've coupled to the 1.8V AREF through a 5kOhm series resistor and accounted for the implied voltage divider with the internal 32kOhm resistance. Is this just bad advice from the Arduino reference, or is it in fact a common practice to do this sort of thing? Is Atmel's statement restricted to external voltages applied to AREF without an external current limiting resistor (and if so why, given the internal 32k resistance)?

As an aside, obviously, one could achieve a similar result with a properly constructed op-amp to scale the 1.8V signals up to 5V, but the added complexity and parts seems wasteful if it can be handled by the on board ADC just as well by taking advantage of the change-able voltage reference. Likewise if you could convince yourself that the sensed signal would not exceed 1.1V you could take advantage of the internal voltage reference. Again, it just seems more elegant to me to use the 1.8V regulator I'm powering my low voltage sensors with to set the reference.

Best Answer

I don't see any problem with applying an external voltage, through a 5 kohm resistor, to the Arduino reference input. Or better, with using a resistor divider, so that you turn 5 V into your desired AREF voltage, while at the same time exhibiting a source resistance of approximately 5 kohm. This second requirement does not have to be accurate. That is just to limit the current that will flow from AVCC to ground, through the external circuitry.


If you want to end up with 1.8 V at the AREF input of the MCU, just choose R1 and R2 so that \$ V_{AREF} = 5ยท\frac{R2||32000}{R1+(R2||32000)} =\$ 1.8 V and \$ R_{source} = R1||R2 \approx\$ 5 kohm.

When you need to work with the [0, 1.8] V range, disable the references internal to the ATMega, and when you need to work with the [0, 5] V, enable the internal AVCC reference (if that is 5 V). If the MOSFET shown in Fig. 24-1 (that connects the internal references to the AREF line) has an on resistance much lower than 5 kohm (which I suppose it has), the internal circuitry will see AVCC. In this second situation, the current drain from the internal AVCC (assumed 5 V) to your external resistor divider will be \$\leqslant\$ 1 mA, but that is not a problem.

In summary: it would be bad advice if something could get damaged, but 1 mA won't damage anything.