How to set one pin as ANALOG all others as DIGITAL, and Vref=Vdd ?


Closed Thread
Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185

    Cool How to set one pin as ANALOG all others as DIGITAL, and Vref=Vdd ?

    For F877,

    On PortA, how do we set AN0 as analog, all others as digital and Vref=Vdd?
    I am trying to have one analog channel and remaining pins as all digital on this port.

    Thanks for the help in advance.


    -------------------
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Set bits 3-0 of ADCON1 to 1110 (as described in the 877 Datasheet DS30292C, page 112) and you will be all set.

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  3. #3
    Join Date
    Jan 2006
    Location
    Istanbul
    Posts
    1,185


    Did you find this post helpful? Yes | No

    Cool

    Thank you Paul.

    In this case, the table shows me, as you already pointed, the following explanation for it; just as I need.

    ADCON1 REGISTER for bit3-0: 1110

    Meaning that:
    AN7=Digital
    AN6=Digital
    AN5=Digital
    AN4=Digital
    AN3=Digital
    AN2=Digital
    AN1=Digital
    AN0=Analog
    Vref+=Vdd
    Vref-=Vss


    After setting the channels and the Vref with Bit3-0 as above, then I need to set Bit7 as 1=Right justified. Then, Bit6-5-4 are left untouched as they are 0.

    Finally, I come up with an ADCON1 register as follows.

    ADCON1=%10001110

    I also set ADCON0= %11000001 to match ADCON1.

    and it works.

    Thanks again for the guidance Paul.
    "If the Earth were a single state, Istanbul would be its capital." Napoleon Bonaparte

Similar Threads

  1. Instant Interrupts - Revisited
    By Darrel Taylor in forum Code Examples
    Replies: 772
    Last Post: - 17th February 2016, 23:14

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