PDA

View Full Version : 12F629 question.



muddy0409
- 3rd January 2006, 13:19
Hi again everyone....
First off, I have RTFM but cannot glean a definate answer to the following:
I want to use the comparator in the 'F629 with the two inputs flagged to GPIO0 and GPIO1 and the output flagged to GPIO2. So far so good, I can see how to do that bit. Now, with the output appearing on GPIO2, can I also set GPIO2 up as an input so as to read the comparator status without having to feed GPIO2 back into another input, say GPIO3?
Does having GPIO2 as the comparator output remove it from being a digital output, which could be read?
Some more night reading coming up, I feel.
Thanks and regards,
Peter Moritz.

Melanie
- 3rd January 2006, 13:36
You missed it in the Datasheet... like they say, if you want to hide something, do it in plain sight!

Look at the CMCON Register bit 6 - COUT (stands for Comparator OUTput). This is the bit you read to get the Comparator Output in software. Example...

If CMCON.6=0 then goto BatteryFlat

The state of this bit additionally depends on your setting of bit 4 - CINV (stands for Comparator INVert).