I'm programming a pic12f675 as a simple comparator, using mplab xide and xc8 compiler. I made a voltage divider (2.5V) as an external reference, and another divider with a pot to create a voltage range of 0 to 3.7V, all verified with a multimeter. I configured CMCON as a non-inverting comparator with output (last three cmcon bits 001). It works perfectly if my main code is:
TRISIO = 0b00000011
ANSEL = 0b00000011
CMCON = 0b00000001
While (1)
{
GPIObits.GP2 = CMCONbits.COUT;
}
but it does not work if I eliminate the GPIObits line and leave the while loop empty, as I thought it should. Configuring the comparator as "with output" should simply place the comparator output at GP2 automatically, shouldn't it?
TRISIO = 0b00000011
ANSEL = 0b00000011
CMCON = 0b00000001
While (1)
{
GPIObits.GP2 = CMCONbits.COUT;
}
but it does not work if I eliminate the GPIObits line and leave the while loop empty, as I thought it should. Configuring the comparator as "with output" should simply place the comparator output at GP2 automatically, shouldn't it?