I have an issue with the Atmega644 and the ADC. I am trying to sample the first four ADC channels which are connected to 20k pots. Each pot is setup as a voltage divider and will output a voltage between ground and 5 volts. The ADC is set to use AREF as the reference voltage, and 5 volts is supplied. I have also tried using AVCC.
My problem is that when I sample the ADC channels I am getting inconsistent results. For example, when I reading the first channel, ADC0, both the first and second pots result in a change in the first sampled value from the ADC. I am using single ended mode, so this should not be the case?
I have provided a copy of the code I am using. The file adccode.c is cut down to include only the relevant ADC code. The file crossover_code.c is the full code for the MCU. I am compiling using GCC-AVR with -Os. Also attached is a copy of the MCU schematic with only the relevant connections included for the ADC and pots.