2
\$\begingroup\$

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.

asked Oct 30, 2012 at 19:51
\$\endgroup\$
3
  • \$\begingroup\$ Comparator input are analog inputs. \$\endgroup\$ Commented 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\$ Commented 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\$ Commented Oct 31, 2012 at 0:09

1 Answer 1

1
\$\begingroup\$

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.

answered Oct 30, 2012 at 21:01
\$\endgroup\$
2
  • \$\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\$ Commented 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\$ Commented Oct 31, 2012 at 12:39

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.