Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

USE PIC16F819 comparators like lm339?

Not open for further replies.


Full Member level 5
May 28, 2011
Reaction score
Trophy points
Activity points
Please i want some notes or tutorial which defines how to use pic16f819 comparator like lm339 to compare volatages?

I can't seem to find an analog comparator on 16F819.

u mean i cant use 16f819 comparator like lm339 to monitor battery voltages with hysteries?

There is no analog comparator (like lm339 or similar) in 16F819, like on some PICs.
All you get in analog is an A/D converter, but You'd have to sample manually to get the value and determine what to do from there.

You might(?) get by if you use an input like RB0 with interrupt on falling edge, and use an resistor divider to trigger the interrupt when battery voltage falls below some value. This is highly NOT recommended, and NOT very reliable solution, but it might work. It would be better to use an schmitt input for something like that. Like RA4 or RA5 (they are Schmitt), but again You'll need to poll the pin.

The comparator You saw in datasheet is part of the CCP module. It compares binary values of Timer1 with predefined limit (so it doesn't go all the way to 0xFFFF).
Another solution would be to use said CCP module to start ADC on overflow (check “special event trigger" in datasheet). And use the ADC interrupt to check periodically.

For reliable operation, a PIC with a comparator or some external circuitry would be best solution. If not possible, I think ADC polling gives better reliability over simple resistor divider and hoping it works.

Not open for further replies.

Part and Inventory Search

Welcome to