I am trying to use the ADC on an ATmega328P clocked at 16 MHz. The datasheet mentions the typical ADC clock frequency range as being from 50 kHz to 200 kHz.

By default, the successive approximation circuitry requires an input clock frequency between 50 kHz and 200 kHz to get maximum resolution. If a lower resolution than 10 bits is needed, the input clock frequency to the ADC can be higher than 200 kHz to get a higher sample rate. The ADC module contains a prescaler, which generates an acceptable ADC clock frequency from any CPU frequency above 100 kHz. The prescaling is set by the ADPS bits in ADCSRA. The prescaler starts counting from the moment the ADC is switched on by setting the ADEN bit in ADCSRA. The prescaler keeps running for as long as the ADEN bit is set, and is continuously reset when ADEN is low.

The prescalers for the ADC clock range from 2 to 128. As I understand it, for remaining 'in the spec' I'd probably require a prescaler of more that 80 i.e. 128.

However, the ADC works for all clock frequencies from CLK/128 up to CLK/4 but not on CLK/2 i.e 8 MHz where it just returns 0x3FF (it is a 10-bit ADC) for all conversions. Is it just because I am running the ADC beyond its recommended maximum or is it something else I need to know about?

ATmega328P Datasheet


It quite clearly says in the data sheet that the ADC clock should not exceed 1MHz. If you break the rules, the behavior is undefined.

It might work, it might not work, it might work only when the moon is full and the temperature is more than 23.7°C or whatever.

enter image description here

Obviously, if your clock is 16MHz, you should not use a lower divider than 16.

  • \$\begingroup\$ That was my initial guess too. But when they say 'undefined behavior' I thought they meant random values popping out of the ADC; 1023 was just too.. 'definite'. I was just looking if there might be any other explanation for it. \$\endgroup\$ – Shrikant Giridhar Jan 25 '14 at 15:27
  • \$\begingroup\$ It's not guaranteed to NOT work at 1.01MHz, but the important thing is that it's not guaranteed to work. One chip might stop working at 3MHz, the next at 1.5MHz. \$\endgroup\$ – Spehro Pefhany Jan 25 '14 at 16:24

In case you are interested to operate the ADC at a high frequency there is an article that shows the bit depth tradeoff for overclocking the atmega adc and an analysis of the adc input stage.

The results of the test show that the effective resolution of the ADC vs clock frequency is like

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.