Trouble reading V_BG I would like to read MUX 14 with the ADC.  On page 263 of the Atmega328 data  sheet it shows 1110b on the MUX corresponding with reading V_BG.

I need to read this so I can calibrate my sensor readings taken with the 5v reference to those taken with the 1.1v reference.  Because the 5v power supply may vary and the 1.1 is more stable, I need to be able to translate the readings taken with a 5v reference based on how the internal 1.1v is read.

Based on the code for analogRead, I wrote this:

int readVBG(int _analogReference) {
  uint8_t low, high;
  ADMUX = (_analogReference &lt;&lt; 6) | 14;
  sbi(ADCSRA, ADSC);
  while (bit_is_set(ADCSRA, ADSC));
  low  = ADCL;
  high = ADCH;
  return (high &lt;&lt; 8) | low;
}


_analogReference is either 1 or 3 depending on the reference voltage desired.

I expect to read 1023 when _analogReference is 3 and about 225 when _analogReference is 1.  Instead I get smaller values which I'm guessing are from a floating (unconnected) analog pin.
The problem is that a 2ms delay is required after setting the ADMUX bits before starting the conversion.  Thank you Majenko for the link.

int readVBG(int _analogReference) {
  uint8_t low, high;
  ADMUX = (_analogReference &lt;&lt; 6) | 14;
  delay(2); // Wait for voltage to settle
  sbi(ADCSRA, ADSC);
  while (bit_is_set(ADCSRA, ADSC));
  low  = ADCL;
  high = ADCH;
  return (high &lt;&lt; 8) | low;
}


The above code is specifically for the Arduino UNO.  Majenko's link above has #ifdef statements which support other devices.