Hi,
First of all you need to configure your comparator modes through the CMCON register.
Syntax : CMCON = %0x0xxxxx
You would find the details from the datasheet about the different modes. Now if you are using the internal reference for your comparator then you need to setup the VRCON register to specify the reference voltage. Same way VRCON =
Now in your application you need to poll the Comparator Output bit CMCON.6 for the comparator status. If you need interrupts then you need to setup the peripheral interrupt registers as well along with the PIE bit in the INTCON. Any change in the comparator status causes an interrupt.
Bookmarks