AVR® Internal Comparator

Last modified by Microchip on 2023/11/09 09:02

Many AVR® devices have an internal Analog Comparator (AC) 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.

AVR Comparator

Comparator Overview

Comparator Setup

A block diagram of the comparator and its surrounding logic.

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.

AVR Comparator Pin Options

Additional Information