Atmega32 and ADC issues

Has anyone had a problem with the analogread function on when using an atmega32?

I connect AVCC to 5V and the AGND. I then connect a potentiometer to a ADC pin, but all I ever get are values ranging from 1016 to 1023 no matter how I adjust the voltage.

Do any of the arduino files need to be modified again to work with the Atmega32? (I already have the atmega32/644 mod files)

Hi, I got the 8 analog input pins on PORTA 0-7 to work using the atmega32 mod I found on a different site,but I can only get outputs from PC6 and PC7 and no PWM's at all.
I am not sure if the pin mappings are completely correct for the atmega32.

posix1965 where did you get your mod?

I havent had any problems with the PWM and I as far as I can tell the pin mapping is correct

I got it from this site....www.retrointerfacing.com I finally got my pin mapping all straight now and all the pins are working even the servo library.

Back to the original question:-

then connect a potentiometer to a ADC pin,

So you connect one end of the pot to +5, the other end of the pot to gnd and the wiper to A0?

AND

I connect AVCC to 5V and the AGND

Are you connecting AGND to 5V, your words say you are but I some how don't think so. If so you shouldn't connect AGND to +5 but to the digital GND.

Back to the original question:-

then connect a potentiometer to a ADC pin,

So you connect one end of the pot to +5, the other end of the pot to gnd and the wiper to A0?

AND

I connect AVCC to 5V and the AGND

Are you connecting AGND to 5V, your words say you are but I some how don't think so. If so you shouldn't connect AGND to +5 but to the digital GND.

I think all the grounds are tied together internally,make sure the AREF which is pin 32 is left not connected.

"So you connect one end of the pot to +5, the other end of the pot to gnd and the wiper to A0?"

Yes

AVCC is +5V
AGND is GND
AREF is unconnected

I tired using all of the ADC channels none of them worked. When I adjust the pot I can read on the oscilloscope the change, but I the values the pins read do seem not reflect any change in voltage. They change values randomly, or not at all depending on the channel.

Hi ,have you tied connecting a meter to the wiper lead of the pot to see if it's good;just a suggestion.

yes, with the oscilloscope I can see that the voltage changes as I adjust the pot

Have you tried using the ATmega32 mod from retrointerfacing?

Posix,

From reading the link you provided, the pin mapping files are the same as the ones already used in the "on to atmega 32" posts on this site. which is where I got mine

I am however running at 4 MHz, do I need to change ADC clock prescaler to reflect this?

Hi, my m32 is running at 14.7MHZ.I am going to recompile my bootloader
and set my chip for 4MHZ to see if I get the same results.I'll let you know.

Hi, I tried my m32 at 4MHZ internal osc. The ADC worked without any other changes.I got an output from 0 to 1023 on the serial output.