Reading ADC10 as analog

Hi

I using the Arduino Micro. I have a problem reading ADC10 (PD7). My simple code for reading is like:

int ReadADC(int channel)
{

// Clear any previous read channel
ADMUX &= ~((1 << MUX4) | (1 << MUX3) | (1 << MUX2) | (1 << MUX1) | (1 << MUX0));	// Clear all ADMUX bits

// Define new ADC Channel to read (which analog pin: 0–5 on ATMega328p
ADMUX |= (channel & 0x0F);

// Start Conversion
ADCSRA |= (1 << ADSC);

// Wait until conversion is finished
while (ADCSRA & (1 << ADSC));

// Return ADC value
return ADCW;

}

Tried other ADCs, reading ADC4 - ADC7 works good.
Any hint is appreciated.
Thanks!

what is wrong with analogRead?

I use the Atmel Studio for development - not the Arduino IDE. So I have to set up the register stuff manually.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.