1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

When to use ADCON1 in c programming on the pic18f8722

  1. Jan 3, 2013 #1
    Under what circumstances would you use ADCON1=0x0F? All I know at the moment is for using the pushbuttons and using the switches and then I saw a piece of code using the pushbuttons without this line in it and I was wondering whether I was wrong all of this time. I have tried googling and looking in the c18 data booklet but I am having problems with my micro at the moment and can't try writing codes myself. Does anyone know?
  2. jcsd
  3. Jan 3, 2013 #2


    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    Many years since I programmed the PIC but..

    ADCON1 is to do with the A-D converter on PORTA. Looks like setting ADCON1 to 0x0F disables the analog input mode for all pins making Port A digital I/O (even though it's probably already set to that mode on Reset).



    So 0F means

    VCFG<1:0> = 00 => Controls the A-D voltage reference
    PCFG<3:0> = 1111 => All pins are Digital I/O

    See page 272.

    In case it's not obvious.. It's not enough just to write to ADCON1. Port A is configured via the TRISA and LATA registers. All three need to be right on a bit by bit basis if you have some that are inputs, some outputs and some Analog Inputs.
    Last edited: Jan 3, 2013
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: When to use ADCON1 in c programming on the pic18f8722
  1. Program in C (Replies: 1)

  2. C++ Program (Replies: 17)