Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

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.

share|improve this question
    
Comparator input are analog inputs. –  Olin Lathrop Oct 30 '12 at 21:47
    
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. –  Jack Oct 30 '12 at 22:32
3  
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. –  Olin Lathrop Oct 31 '12 at 0:09
add comment

1 Answer

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.

share|improve this answer
    
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? –  Jack Oct 30 '12 at 21:15
    
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. –  Brandon Bailey Oct 31 '12 at 12:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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