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.