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.
Bookmarks