I'm trying to use Port F on the PIC18F65J11 as both analog inputs and a comparator. For example, there are 7 pins on Port F, and I'd use 3 pins for comparator (2 comparator inputs, 1 comparator output) and the rest for analog inputs.

I know that you can configure it so that comparators are enabled, or you can turn of comparators. I'm reading the data sheet, and I'm confused how to configure it so that I can use comparator and analog inputs on Port F at the same time, if that's possible.

For reference, here's the data sheet: http://ww1.microchip.com/downloads/en/DeviceDoc/39774d.pdf. Page 143 talks about Port F. Page 260 talks about analog inputs. Page 270 talks about comparator module.

  • \$\begingroup\$ Comparator input are analog inputs. \$\endgroup\$ Oct 30, 2012 at 21:47
  • 1
    \$\begingroup\$ If I configure that port to use comparator, is that analog input only feed into the comparator? If it only feeds into the comparator, I won't be able to read what that value is. \$\endgroup\$
    – Jack
    Oct 30, 2012 at 22:32
  • 3
    \$\begingroup\$ This is getting silly. It's time to actually READ THE DATASHEET. Nothing prevents more than one analog peripheral from reading the same analog pin, assuming of course they can each be configured for that pin. \$\endgroup\$ Oct 31, 2012 at 0:09

1 Answer 1


Take a look at the chart on page 260 of the datasheet. ADCON1 is the register I believe you want to take a look at.

  • \$\begingroup\$ Just looking on that table, it looks like I can configure desired ports to be analog inputs. But, the chart on 270 showing the comparators with bits 2:0 of CMCON register set to 001 (one comparator on, one off) makes it seem like the other pins will become digital. You think the pins on the comparator that's turned off can be used as analog input if set with ADCON1? \$\endgroup\$
    – Jack
    Oct 30, 2012 at 21:15
  • \$\begingroup\$ Yes as Olin states above there is nothing that prevents you from "reconfiguring" a pin within your program. Just make sure to take into account all the registers that are affected by the module you are using (eg. comparator, adc...) and make sure the port pin you are using supports the use of both modules you are wanting. \$\endgroup\$ Oct 31, 2012 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.