ADCON1 settings 18F4620


Closed Thread
Results 1 to 9 of 9
  1. #1
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96

    Red face ADCON1 settings 18F4620

    Hello,
    I want to set up 4 of the 13 availiable A2D converter pins on my 18F4620. Can someone clarrify for me......

    If I want to set up AN0, AN1, AN4 & AN12 (8 bit resolution only) and leave every other pin on PORTA & B as digital input/ouputs.....

    will this do the trick?


    ADCON1.0=0
    ADCON1.1=0
    ADCON1.4=0
    ADCON1.12=0

    'tristates will already be defined above
    Padawan-78

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by earltyso View Post
    Hello,
    I want to set up 4 of the 13 availiable A2D converter pins on my 18F4620. Can someone clarrify for me......
    If I want to set up AN0, AN1, AN4 & AN12 (8 bit resolution only) and leave every other pin on PORTA & B as digital input/ouputs.....
    will this do the trick?
    ADCON1.0=0
    ADCON1.1=0
    ADCON1.4=0
    ADCON1.12=0
    'tristates will already be defined above
    Nope, doesn't work that way.
    You can only have the analog ports the way the datasheet for the 18F4620 shows in DS39626B, page 224, under the heading Register 19-2.
    As you'll see, ADCON only has 8 bits. ADCON1.12...not enough bits in ADCON for that.
    Basically, you have to start at AN0 and add AN1, then AN2, then AN3, and so on until you get enough analog ports.

  3. #3
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    Thanks for the help, I have read the data sheet for using ADCON1, ADCON2 registers and I am still confused on how to use the table on page 226. Can you lend a hand.
    I think I need to use ADCON2 to enable AN12.

    Something like....
    ADCON2.4 = 0 '????????
    Padawan-78

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by earltyso View Post
    Thanks for the help, I have read the data sheet for using ADCON1, ADCON2 registers and I am still confused on how to use the table on page 226. Can you lend a hand.
    I think I need to use ADCON2 to enable AN12.

    Something like....
    ADCON2.4 = 0 '????????
    Re-READ my post again...
    Then Read the A/D chapter in the datasheet.
    The ADCON registers don't work that way.
    Question for you...
    What does ADCON0 do?
    What does ADCON1 do?
    What does ADCON2 do?

    Table on page 226? Which version of the datasheet do you have?

  5. #5
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    ADCON0 controls operation of A/D module
    ADCON1 configs functions of port pins
    ADCON2 configs A/D clock source

    this is page 224 DS39626, page 226 in pdf view
    Padawan-78

  6. #6
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Default

    OK, here is what I do understand,

    for ADCON1 control register.....I need...

    bit 7 = 0
    bit 6 = 0
    bit 5 = 1 'I am using Vref- AN2
    bit 4 = 1 ' I am using Vref+ AN3

    what I still don't understand....from page 224

    bit 3 = ?
    bit 2 = ?
    bit 1 = ?
    bit 0 = ?
    Padawan-78

  7. #7
    Join Date
    Oct 2004
    Location
    Hangover, Germany
    Posts
    289


    Did you find this post helpful? Yes | No

    Red face

    Some trick:

    If there are analog signals on inputs, they can drive the current through the inputs to an high level, if they are digital inputs !

    So,
    you can declare all the inputs as analog and switch them to digital in the case of reading a digital input and switch them back to analog after (ADCON1).

    You can switch all the AN3... to digital and see what happens ;-)
    You can read the analog value without problems!

    You can arrange the analog inputs on the first AN-channels !!!!!!
    PBP 2.50C, MCS+ 3.0.0.5, MPLAB 8, MPASM 5.14, ASIX Presto, PoScope, mE mikroBasic V7.2, PICKIT2

  8. #8
    Join Date
    Jan 2007
    Location
    Houston, TX
    Posts
    96


    Did you find this post helpful? Yes | No

    Thumbs up Got err done

    Duh,
    Got It!
    I cannot pick and choose around which inputs I want I have to start with AN0 and work my way up or not at all.
    thanks for the blunt yet helpful comments!
    Just had to figure out how to read the table....had to look at the big picture.
    Padawan-78

  9. #9
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by earltyso View Post
    Duh,
    Got It!
    Great! And believe it or not, that one little table and the way it is written and works, ties into soooo much other PIC stuff...so you didn't learn one thing...you learned a hundred things...just not all at once...YET...
    Problem is...now you'll be up until all hours of the morning trying to figure out what to do next with all that new knowledge...

Similar Threads

  1. Confused over A/D settings
    By malc-c in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd February 2010, 10:44
  2. LM35DZ and 18F2455 settings
    By Mark J in forum mel PIC BASIC Pro
    Replies: 18
    Last Post: - 25th January 2008, 08:31
  3. Config settings
    By Adrian in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th December 2007, 18:24
  4. ADCIN - AD settings are wrong
    By teverett in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th December 2006, 16:32
  5. Help with setting adcon1 for 16f877
    By jessey in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 16th August 2005, 11:13

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts