Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0


Closed Thread
Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2011
    Posts
    2

    Default Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0

    I am using an 18F4525 and I would like to use PortA as inputs. I am using an external osc, so pins RA6 and RA7 are allocated for that function. I have configured PortA to be all inputs, but when I read the port with logic 1 on the inputs, RA2 and RA3 always show 0. Can someone point out what I am doing wrong? Thank you.

    porta = %00000000
    adcon1 = %11111111 ' PortA - Set to digital
    cmcon = %00000111 ' Disable Comparators
    trisa = %11111111 ' PortA - All Inputs
    trisb = %00000000 ' PortB - All Outputs

    statusloop: portb = porta
    pause 500
    goto statusloop

    I have LEDs on all PortB pins and bits 0, 1, 4, & 5 follow the logic placed on the corresponding PortA pins. Bits 2 and 3 always show 0.

  2. #2
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0

    maybe this is the problem?:
    Note: On a Power-on Reset, RB4:RB0 are
    configured as analog inputs by default and
    read as ‘0’; RB7:RB5 are configured as
    digital inputs.
    By programming the Configuration bit,
    PBADEN, RB4:RB0 will alternatively be
    configured as digital inputs on POR.
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  3. #3
    Join Date
    Mar 2011
    Posts
    2


    Did you find this post helpful? Yes | No

    Default Re: Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0

    In my full program I flash all of the LEDs on PortB to show that PortB is working correctly and they do all flash as I would expect them to. I believe that it is something with the configuration of PortA, but I don't know what! Thank you.

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


    Did you find this post helpful? Yes | No

    Default Re: Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0

    Try adcon1 = %00001111. With adcon1 = %11111111 you have RA2 and RA3 set for Vref- & Vref+.
    Regards,

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

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: Using 18F4525 with PortA defined as all inputs - RA2 and RA3 always show logic 0

    I doubt this is it, but can you try it with
    Code:
    adcon1 = %11001111
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

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