SAM D21 Analog Comparator Overview

Introduction to Analog Comparator

The Analog Comparator (AC) is a module that compares two analog input voltages and outputs a signal level indicating which of the inputs is greater. An AC is basically an amplifier without feedback and thus has a very high gain.

The figure below shows the basic symbol of an analog comparator. Typically, an AC compares voltage levels on two inputs and gives digital output based on the comparison. When the voltage on the positive input (Vin0) is greater than the voltage on the negative input (Vin1) then the output voltage (VOUT.) is saturated to its positive supply (+VSUPPLY), otherwise the output is saturated to is negative supply (-VSUPPLY).

In MCUs, since there is no negative supply voltage, GND (ground level) is taken as –VSUPPLY and VCC level is taken as +VSUPPLY.


Analog Comparator in SAM D Devices

The AC module in SAM D MCUs implements two individual comparators. Each comparator compares the voltage levels on two inputs and provides a digital output based on the comparison. Each comparator may be configured to generate interrupt requests and/or peripheral events upon several different combinations of input change.

The figure below shows the block diagram of the AC in SAM D MCUs. Each comparator has one positive input and one negative input. Each positive input may be chosen from a selection of analog input pins while each negative input may be chosen from a selection of analog input pins or internal inputs, such as a bandgap reference voltage. The digital output from the comparator is one when the difference between the positive and the negative voltage is positive and zero otherwise.


The comparators are always grouped in pairs on each port. The AC module may implement one pair. These are called Comparator 0 (COMP0) and Comparator 1 (COMP1). They have identical behaviors but have separate control registers. Each comparator has one positive and one negative input.

 Learn More

Analog Comparator Configuration
Learn more >
Analog Comparator Example Project
Learn more >
© 2018 Microchip Technology, Inc.
Notice: ARM and Cortex are the registered trademarks of ARM Limited in the EU and other countries.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.