Question Regarding Port A on 16F876A


+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2009
    Location
    Bozeman, Montana (USA)
    Posts
    2

    Default Question Regarding Port A on 16F876A

    I am utilizing all of the I/O Pins on a 16F876A. I would like to configure port A with 3 analog pins (AN0-AN2) and utilize RA3-RA5 as general purpose IO pins.

    Based on the data sheet and its reference to configuring the ADCON1 register it does not look like this is possible. I am wondering what happens if I configure the entire port as an analog port then simply convert RA3-RA5 as outputs? For Example:

    ADCON1 = 2 ' CONFIGURE PORT A TO ANALOG (010)
    TRISA.3 = 1 ' CONFIGURE PIN AS INPUT
    TRISA.4 = 0 ' CONFIGURE PIN AS OUTPUT
    TRISA.5 = 0

    If I read or write to RA3-RA5 as analog inputs or outputs what affect does this have on AN0-AN2?

    Any input appreciated.

    Best regards,
    Joe.

  2. #2
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default

    If I read or write to RA3-RA5 as analog inputs or outputs what affect does this have on AN0-AN2?
    Surely you ment digital, the answer is none.

    Suggest to use portA.3 as an output and portA.4 as an input since A4 is an open-drain type

    Alberto
    All progress began with an idea

  3. #3
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    If you write to an analog pin, set as an output, results will differ from time to time, so Just don't do that

    Better practice is to modify your hardware assignment to what your PIC can do, and/or choose another PIC which have more flexibility about analog pin configuration.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  4. #4
    Join Date
    Feb 2009
    Location
    Bozeman, Montana (USA)
    Posts
    2


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by aratti View Post
    Surely you ment digital, the answer is none.

    Suggest to use portA.3 as an output and portA.4 as an input since A4 is an open-drain type

    Alberto
    Thank you for writing what I was thinking! Yes you are correct. I guess I am confused about the configuration of ADCON1 register, particularly bits 0-3. It appears this configures the port as whole and this determines which pins can/will be analog inputs or digital IO pins. In particular I read this post which concerns me:

    http://www.picbasic.co.uk/forum/show...ghlight=ANALOG

    Since the PCB is already developed it concerns me that the I/O pins can only be configured per the chart in the datasheet. So, if this is configured so that all pins are analog then specific pins are converted after that to digital I/Os what impact does this have. If these pins can be individually configured why is the ADCON1 register even needed?

    Thanks,

    Joe

Similar Threads

  1. 16F876A CCP1 Capture/Interrupt Question
    By TDonBass in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 17th January 2008, 03:25
  2. AN Question for "word" variable read The serial port
    By redfoen in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th December 2007, 17:39
  3. Another question RE port line indexing
    By muddy0409 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 7th August 2007, 15:23
  4. Microcontroller with 2 way paging application problem
    By oneohthree in forum mel PIC BASIC Pro
    Replies: 30
    Last Post: - 20th April 2007, 17:27
  5. Question on assigning pin port to variable
    By khufumen in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 1st June 2005, 22:25

Posting Permissions

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