Atmega328p-AU Aref pin ADC as digital output

I am using a Atmega328p-au for a project where I am using the ADC with a Voltage reference of 2.048V attached to Area pin on the microcontroller. I found in the data sheet that some of the ADC channels use the AREF voltage (2.048V) and some use the 5V VCC. ADC 0-3 and 7 are Aref and ADC 45/6(not sure about 6) use the 5V
Atmega328p-au Datasheet

My question is, I need more digital pins and I am not using all of the ADC pins, if I set one of the analogue pins ,that use AREF, as an output and set high, will it be 2.048V or 5V ?

I may run the 328P at 3.3v but I guess it would be the same issue.

Any help will be appreciated.

Thank you,
Harvey :slight_smile:

All of the analog inputs use the same analog reference.

The analog inputs are digital inputs with analog input as a special function. When set to OUTPUT all digital pins will output 0 or Vcc. The analog reference has NO effect on digital outputs or inputs.

And... There is only ONE multiplexed (shared) ADC inside the chip.

Since you only read one pin at a time, you could change the reference between readings but but might need a delay for some settling/stabilization time.

1 Like

Or read the analog input twice after the change, discarding the first reading.

@groundFungus
Thank you very much for the quick and helpful response, what does it mean by using digital supply voltage?

The measurements I'm taking need to be precise, I'm just worried having the reference on the VCC rail could create some errors/peaks or am I just overthinking this.

@DVDdoug
Also thank you, luckily my issue is not as complicated as needing to change the reference, but it is nice to know for future projects :slight_smile:

Thank you again,
Harvey :slight_smile:

Sorry, I am unsure what you mean by that question. Digital supply voltage is Vcc.

No you are right to be concerned. If Vcc is not stable it will show up in Vref if using the default analog reference. There are a lot of things that can effect Vcc. You can use a precise external reference or use the 1.1V internal reference and use a voltage divider to drop your measurand to less than 1.1V peak. Now the 1.1V is not necessarily exactly 1.1V, but it will be close and it will be stable at that value. Use 1% or better resistors in the voltage divider, calibrate the divider and measure the actual value of Vref to calibrate.

That is why the part of the data sheet you posted said you should use a low pass filter between the VAcc pin and the Vcc pin. This smooths the supply to ADC.

It will be 5V. The value on the AVcc pin has nothing to do with using analogue pins as outputs.

Not so much over thinking, but getting hold of the wrong end of the stick.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.