PICBASIC Pro commands for using analog comparator module for PIC16F628
I would like to use the analog comparator module so that 2 input into the comparator will result in one output from it. But I have problems with the syntax used in the PICBASIC Pro.
Can anyone please kindly help me for the commands that i need and also any circuit diagrams in using the analog comparator that may help.
Thanks a lot for help..:)
You need to manually read/write registers.
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.