Datasheet
ATmega48PA/88PA/168PA [DATASHEET]
9223F–AVR–04/14
210
23. Analog Comparator
23.1 Overview
The analog comparator compares the input values on the positive pin AIN0 and negative pin AIN1. When the voltage on the
positive pin AIN0 is higher than the voltage on the negative pin AIN1, the analog comparator output, ACO, is set. The
comparator’s output can be set to trigger the Timer/Counter1 Input capture function. In addition, the comparator can trigger a
separate interrupt, exclusive to the analog comparator. The user can select Interrupt triggering on comparator output rise,
fall or toggle. A block diagram of the comparator and its surrounding logic is shown in Figure 23-1.
The power reduction ADC bit, PRADC, in Section 10.10 “Minimizing Power Consumption” on page 37 must be disabled by
writing a logical zero to be able to use the ADC input MUX.
Figure 23-1. Analog Comparator Block Diagram
(2)
Notes: 1. See Table 23-1 on page 210.
2. Refer to Figure 1-1 on page 3 and Table 14-9 on page 76 for analog comparator pin placement.
23.2 Analog Comparator Multiplexed Input
It is possible to select any of the ADC7...0 pins to replace the negative input to the analog comparator. The ADC multiplexer
is used to select this input, and consequently, the ADC must be switched off to utilize this feature. If the analog comparator
multiplexer enable bit (ACME in ADCSRB) is set and the ADC is switched off (ADEN in ADCSRA is zero), MUX2...0 in
ADMUX select the input pin to replace the negative input to the analog comparator, as shown in Table 23-1. If ACME is
cleared or ADEN is set, AIN1 is applied to the negative input to the analog comparator.
Bandgap
Reference
Interrupt
Select
AIN0
VCC
ACIS1
ADC Multiplexer
Output
(1)
ACIS0 ACIC
ACO
ACIE
Analog
Comparator
IRQ
ACI
To T/C1 Capture
Trigger MUX
ACBG
ACME
ADEN
ACD
+
-
AIN1
Table 23-1. Analog Comparator Multiplexed Input
ACME ADEN MUX2...0 Analog Comparator Negative Input
0 x xxx AIN1
1 1 xxx AIN1
1 0 000 ADC0
1 0 001 ADC1
1 0 010 ADC2
1 0 011 ADC3
1 0 100 ADC4
1 0 101 ADC5
1 0 110 ADC6
1 0 111 ADC7