202
Atmel ATmega16/32/64/M1/C1 [DATASHEET]
7647K–AVR–12/13
Figure 18-7. ADC Timing Diagram, Free Running Conversion
18.5
Changing Channel or Reference Selection
The MUXn and REFS1:0 bits in the ADMUX Register are single buffered through a temporary register to which the CPU has
random access. This ensures that the channels and reference selection only takes place at a safe point during the conversion.
The channel and reference selection is continuously updated until a conversion is started. Once the conversion starts, the
channel and reference selection is locked to ensure a sufficient sampling time for the ADC. Continuous updating resumes in the
last eight ADC clock cycle before the conversion completes (ADIF in ADCSRA is set). Note that the conversion starts on the
second following rising CPU clock edge after ADSC is written. The user is thus advised not to write new channel or reference
selection values to ADMUX until two ADC clock cycle after ADSC is written.
If auto triggering is used, the exact time of the triggering event can be indeterministic. Special care must be taken when
updating the ADMUX register, in order to control which conversion will be affected by the new settings.
If both ADATE and ADEN is written to one, an interrupt event can occur at any time. If the ADMUX register is changed in this
period, the user cannot tell if the next conversion is based on the old or the new settings. ADMUX can be safely updated in the
following ways:
1.
When ADATE or ADEN is cleared.
2.
during conversion, with taking care of the trigger source event, when it is possible.
3.
After a conversion, before the interrupt flag used as trigger source is cleared.
When updating ADMUX in one of these conditions, the new settings will affect the next ADC conversion.
Table 18-1. ADC Conversion Time
Condition
First Conversion
Normal Conversion,
Single Ended
Auto Triggered
Conversion
Sample and Hold
(Cycles from Start of Conversion)
13.5
3.5
2
Conversion Time
(Cycles)
25
15.5
16
12
13
14
1
2
3
4
5
Cycle Number
One Conversion
Sign and MSB of Result
LSB of Result
Next Conversion
MUX and REFS
Update
Conversion
Complete
ADC Clock
ADSC
ADIF
ADCH
ADCL
Sample and
Hold