Hello,
I'm trying to enable the 2.56v voltage on the Aref pin of my Arduino Mega. I already tried numerous ways to write a "1" to bit 6 and 7 of the ADMUX register in C code but every time I measure 0v over the Aref pin..
2 questions:
1. How can I correctly measure the pin (Aref)? by placing a resistance between the pin and gnd, and then measure to voltage over the resistor?
2. Does anyone have an idea on how to enable this using Flowcode or C code?
Coensk
Enabling 2.56v reference voltage on Arduino Mega
Moderator: Benj
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Enabling 2.56v reference voltage on Arduino Mega
Hi,
Have a look at this post ...
http://www.matrixtsl.com/mmforums/viewt ... 54&t=18416
Also, the Atmel datasheet (p275) has this note ...
VREF can also be measured at the AREF pin with a high impedant voltmeter.
Note that VREF is a high impedant source, and only a capacitive load should be connected in a system.
If the user has a fixed voltage source connected to the AREF pin, the user may not use the other reference voltage
options in the application, as they will be shorted to the external voltage. If no external voltage is applied to the
AREF pin, the user may switch between AVCC, 1.1V and 2.56V as reference selection.
Have a look at this post ...
http://www.matrixtsl.com/mmforums/viewt ... 54&t=18416
Also, the Atmel datasheet (p275) has this note ...
VREF can also be measured at the AREF pin with a high impedant voltmeter.
Note that VREF is a high impedant source, and only a capacitive load should be connected in a system.
If the user has a fixed voltage source connected to the AREF pin, the user may not use the other reference voltage
options in the application, as they will be shorted to the external voltage. If no external voltage is applied to the
AREF pin, the user may switch between AVCC, 1.1V and 2.56V as reference selection.
Re: Enabling 2.56v reference voltage on Arduino Mega
Thanks LeighM,
Can i just use this component macro "RawEnable" and "RawSampleByte" with the C code in between, once at the beginning of my program and the ADMUX bits will stay enabled throughout the program?
Coensk
Can i just use this component macro "RawEnable" and "RawSampleByte" with the C code in between, once at the beginning of my program and the ADMUX bits will stay enabled throughout the program?
Coensk
- LeighM
- Matrix Staff
- Posts: 2178
- Joined: Tue Jan 17, 2012 10:07 am
- Has thanked: 481 times
- Been thanked: 699 times
Re: Enabling 2.56v reference voltage on Arduino Mega
Hi,
It's going to get quite complex that way.
I think that the quickest way is to edit \CAL\AVR\AVR_CAL_ADC.c
(best to make a backup first, and make a note to yourself that you now have a custom version
Line 700 currently looks like this ..
Change it to this ...
Then you can use the Flowcode ADC component macros in the usual way.
Hope that helps,
Leigh
It's going to get quite complex that way.
I think that the quickest way is to edit \CAL\AVR\AVR_CAL_ADC.c
(best to make a backup first, and make a note to yourself that you now have a custom version

Line 700 currently looks like this ..
Code: Select all
ADMUX = (Vref << REFS0) | (1 << ADLAR) | Chan;
Code: Select all
// Internal 2.56V Voltage Reference with external capacitor at AREF pin
ADMUX = (0xC0) | (1 << ADLAR) | Chan;
Hope that helps,
Leigh