PIC16F877 PORTA Input Issue


Closed Thread
Results 1 to 8 of 8
  1. #1

    Default PIC16F877 PORTA Input Issue

    I'm trying to configure porta.3 and porta.4 for input on a 877 chip and can not for the life of me get it to work properly. I have the I/O pulled to +5V and it still keeps registering that both ports are 0 for there state. Is there something I missed in the configuration?

    Code:
        ADCON1 = %00001111      
        ADCON0 = 0
        CCP1CON = 0             ' Turn off Capture/Compare/PWM module 1
        TRISA = %00011011       ' All outputs except for A0,A1,A3,A4

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    CCK,

    Are you sure it's not a 16F877A

    If it is, you'll also need   CMCON = 7
    <br>
    DT

  3. #3


    Did you find this post helpful? Yes | No

    Default

    It is actually the 877 and not the 877A. I thought the same thing at first until I double checked the actual chip. I did however since discover the issue. It has some to do with Bit7 for the ADCON1 register. I made it 1 instead of 0 and everything seems to work fine now. I don't understand why because the A/D is turned off for the justification I would not think would have any bearing on this matter but it seems to.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default What!

    You've GOT to be kidding!

    That's the strangest thing I've ever heard about PIC's.

    I use ADCON1=7 alot, and have never had to ADCON1=$87 for digital inputs. And, ADCON1=6 works well too.

    Is it repeatable? Changing ADCON1.7 back to 0, causes the same thing again?
    <br>
    DT

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Well this makes no sense but I just checked it again with a 0 and it now works. I'm not sure what to make of this. Maybe I changed something else and forgot that I did that. Not sure what to make of it. It seems to work fine now

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    ADCON1 = %00001111 is setting RA0 as A/D in, RA2 as -Vref & RA3 as +Vref.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7


    Did you find this post helpful? Yes | No

    Default

    What does it mean when the datasheet says "Bit is unknown"? How do you make all the ports digital because the datasheet says 011x with x being an unknown?

  8. #8
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    X in this case means it doesn't matter what the bit is. ADCON1 = %00000111 or ADCON1 = %00000110 will have the same effect.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

Similar Threads

  1. PIC Interrupt and PORTA input
    By Jerade in forum mel PIC BASIC
    Replies: 5
    Last Post: - 29th November 2009, 17:24
  2. PortA digita input?
    By MOUNTAIN747 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th January 2009, 21:55
  3. Timing input pulses and re-outputting them
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 28th February 2007, 01:50
  4. Wierd sleep issue
    By orca in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 14th March 2006, 22:06
  5. Can anyone help a beginner in a struggle?
    By douglasjam in forum mel PIC BASIC
    Replies: 1
    Last Post: - 5th May 2005, 23:29

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