5.4.3 Analog Comparator (AC/CMP)

Analog Comparators (AC/CMP) compare the voltage levels of two inputs and provide a digital output based on the comparison. The PIC16F, PIC18F, and PIC32CM ACs offer features suitable for zero-cross detection, threshold monitoring, and windowed analog signal analysis. Table 5-16 provides a comparison of features between PIC16F, PIC18F and PIC32CM.

Table 5-16. PIC16F, PIC18F and PIC32CM AC Features
FeaturePIC16F CMPPIC18F CMPPIC32CM AC
Number of Comparators2–82, 32–4
Output on Pin SupportedSupportedSupported
Input Selection

Four external inputs

DAC

FVR

VSS

Four external inputs

DAC

FVR

VSS

Internal ground

Four pins (positive/negative)

Ground band gap

DAC

AVDD scaler (64-level)

Internal Reference

FVR

DAC

FVR

DAC

Band gap

DAC

AVDD scaler

Hysteresis SelectableSelectableSelectable
Output Inversion Supported Supported Supported
Interrupt GenerationRising, Falling, or any edgeRising, Falling, or any edgeRising, falling, toggle, end of comparison Window function
Window ModeN/A

Through software

N/A

Through ADC

Yes (window function, window interrupts/events)
Event GenerationTriggers ADC, Timers, or PWM shutdown (CWG)Triggers ADC, Timers, or PWM shutdown (CWG)Comparator output, window function (in/out)
Response TimeSelectableSelectableSelectable
Digital FilterSupported for some devicesN/ASupported
Output OptionsDigital output, interrupt, PWM shutdownDigital output, interrupt, PWM shutdownDigital output, interrupt, event trigger
Window/Zero-Cross DetectionSupportedSupportedSupported (window mode, zero-cross, advanced)
Filtering/DebounceSupportedSupportedSupported (programmable filtering)
Low Power OperationSupportedSupportedSupported (sleepwalking, event-driven)
Interrupt on Output ChangeSupportedSupportedYes