PIC16F628 Help needed, comparator wont compare

Status
Not open for further replies.

2camjohn

Member
I have recently switched my comparator on my PIC16f628 over from using an external reference voltage to the internal one.

THe problem is the state of the comparator doesnt change anymore.


Here is some pseudocode of a test program:

CMCON = %00000100 'set up internal comparator
VRCON = %10100010 'set up voltage reference module
TRISA = %11111100 'set all porta as input
TRISB = %11110000 'set portb


start:
High PORTA.6

While CMCON.0 = 1
Low PORTA.6
Wend

Goto start


I have checked the value of my reference voltage and it falls between the high and low values.

Its just meant to switch the light on and off as the comparator changes, but the light remains on.

Can someone help.

Thanks
 
The CMCON setting you currently use doesn't connect the reference output to a comparator input...

you might want to take a look at the comparator IO operating modes in the datasheet again
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…