# AVR ADC multiplexer odd behaviour

I noticed strange behaviour, for which I cannot find any documented confirmation. In my program I measure two ADC channels:

• Internal 1.1 V bandgap reference (in order to know the value of applied supply voltage VCC)

I measure these two channels by polling. It seems when I measure a channel I always get the value of the previous measured channel at first. To get the actual correct value I have to wait some time (delay) and measure again. Why is this? This is my code for reading the ADC values.

ADCSRA &= ~(1<<ADEN); /* ADC ausschalten */

/* Set VCC as reference for ADC */

ADMUX &= ~((1<<MUX4) | (1<<MUX3) | (1<<MUX2) | (1<<MUX1) | (1<<MUX0));

/* At this point I read a wrong value (from previous channel) */

/* My current workaround starts here */
_delay_us(50); /* Wait some time */

/* Measure again */

/* Now I got my correct value */



When reading the 1.1 V bandgap the only thing I change from the code above is:

/* Measure 1V1 bandgap reference (ADCSRB[MUX5] = 0b0; ADMUX[MUX4-MUX0] = 0b11110)*/