analogReference Not declared

Hi,

I'm using standalone atmega2560 for a custom PCB.
I didn't connect the Aref pin when designing. Now I'm wondering, if the data read from Analogs Pins is correct.

I have power supply at 3.3V.

Thank you

Post the code, using code tags, and the complete error message.

Since that error message is fatal, the code could not have been run. For answers to your question, post the code that led to it.

I didn't connect the Aref pin when designing.

Standard procedure is to put a small cap from the pin to GND, but if the pin is not exposed, it probably does not matter.

Unless you change it using the analogReference() function the analogReference will be the default reference and that is Vcc. Vcc is nominally 5V on a Mega. For best accuracy, Vref should be measured and the actual value of the analog reference voltage should be used in any calculations to get voltage from ADC counts (raw ADC output from analogRead()).

The analog reference (Vref) pin should not be connected to any external voltage unless, and only unless, the analog reference is set to EXTERNAL. See the Notes and Warnings on the analogReference function reference page.

You can improve the stability of analog readings by connecting a 0.1uF ceramic cap from the analog reference pin to ground.

Thnks for your reply

If I understand correctly the Vref if I leave the pin unconnected, it turns out to be VCC.
In my case it's 3.3V but you tell me that Mega2560 is usually 5. If I measure the voltage on the Vref pin and put that value in my calculations should I be safe?

What clock frequency?

If your board's Vcc is 3.3V then Vref, with the default reference, is 3.3V nominal.

And, yes, measure the actual value of Vcc and use that value in calculations for best accuracy.

Yes, but the accuracy now depends on the stability of that 3.3V , so power supply voltage should be very stable..

The minimum Vcc for ATmega2560 is 4.5 volts.
It might run at 3.3 volts, but nothing is guaranteed.

4.5v is the minimum at 16Mhz
The data sheet shows a minimum voltage of 1.8 volts , but that would be at a slower clock rate . Not looked the sheet but 8MHz might be fine at 3.3v

1.8 volts is for 2560V (max 8 MHz), not 2560.


A 1280 can run at 3.3 volts 8 MHz.

Ok, I mesured Vref an is 3.3V.
I have 3.3V stable voltage on VCC.

I use 3.3V at 4MHz internal.

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