Quote Originally Posted by HenrikOlsson View Post
Hi,
The way you have CMCON configured the comparators are set up like this:
Attachment 6347

You have your inputs connected to RA0 and RA2. CMCON.7, which you've aliased is the output of comparator 2...

In order to use the internal reference voltage module you must set the comparator mode to 110 instead of 101. Further on, you seem to think that RA2 is the reference input but it's not. It can optionally be the reference output. From the datasheet:

Finally, I can't seem to find a register called VRCON in the datasheet, it's CVRCON.

You need to decide what to actually do, either use the internal reference and set it up correctly or use external "reference" and connect it to correct pins.

/Henrik.
1. VRCON register is for internal Vref and is found within a data sheet
2. CM2:CM0=101 i found from the data sheet and is for "one independent comparator"
3. from the data sheet i found RA2 is the refereence input
4. i want to use external fererence as i show in my circuit , i used RA2 as reference
5. i use pic16f627a/628a/648a datasheet, i found that i configured well but i think the problems are in the loop, check well
6. still i have a problem Henrik, so ask help on this and it will be better when you stimulate this circuit so that you can see how it perfom wrongly