Many AVR devices have an internal Analog Comparator peripheral that 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.
Comparator Overview
Comparator Setup
Comparator Interrupts
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.
Comparator Negative Input Pin Options
It is possible to select any of the ADC[7: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 in the ADC Control and Status Register B ADCSRB.ACME is '1' and the ADC is switched off ADCSRA.ADEN=0, then the three least significant Analog Channel Selection bits in the ADC Multiplexer Selection register ADMUX.MUX[2:0] select the input pin to replace the negative input to the Analog Comparator.
When ADCSRB.ACME=0 or ADCSRA.ADEN=1, AIN1 is applied to the negative input of the Analog Comparator.