Input problems with PortD on Pic16F874A


Closed Thread
Results 1 to 9 of 9

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Kalmar in sweden
    Posts
    5

    Angry Input problems with PortD on Pic16F874A

    Hi,
    I have some serious problems, I need to use PortD.0 to PortD.3 for digital I/O.
    It just wont work,!!!
    I have read that:
    “PortD is also the PARALLEL SLAVE PORT. To make it a general purpose I/O port, Bit4 of TRISE must be set to 0 IE TRISE.4 = 0”

    So I tried:
    TRISE.4=0

    And to be on the safe side I also tried:
    ADCON1 = 7
    CMCON=7
    TRISD = %11111111

    And it still doesn’t work, does anyone have an idea?



    / Petter

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


    Did you find this post helpful? Yes | No

    Default

    What are you trying to do that doesn't work? It's hard to tell with just
    TRISD = %11111111.
    Regards,

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

  3. #3
    Join Date
    Aug 2006
    Location
    Kalmar in sweden
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Input problems with PortD on Pic16F874A

    Hi Bruce.
    I am trying to use PortD.0 to PortD.3 as digital input.

    “IF PortD.0 = 1 THEN…”
    and it doesn’t work.


    / Petter

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


    Did you find this post helpful? Yes | No

    Default

    IF PortD.0 = 1 THEN
    Are you holding the pin at ground with a pull-down resistor until a button is
    pressed taking the input high?

    I don't have a 16F874A, but I do use the 16F876A with PORTD inputs, and
    it works as expected.

    It might help is you showed all your code & a schematic.
    Regards,

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

  5. #5
    Join Date
    Aug 2006
    Location
    Kalmar in sweden
    Posts
    5


    Did you find this post helpful? Yes | No

    Default Input problems with PortD on Pic16F874A

    Hi again.

    Yes, I am using pull-down resistor on all my inputs.
    I will try to find some free time tomorrow to post my code & schematic.

    / Petter

  6. #6
    Join Date
    Aug 2006
    Location
    Kalmar in sweden
    Posts
    5


    Did you find this post helpful? Yes | No

    Default

    Hi
    This is my testcode & schematic:

    '---------------------------------
    Include "modedefs.bas"
    @ DEVICE HS_OSC
    DEFINE OSC 20
    ADCON1 = 7
    CMCON=7
    TRISE.4=0
    LED VAR PORTB.5

    boot:
    Pause 500
    Low led
    high porta.0

    LOOP:
    if portc.2 = 1 then high ut10
    if portc.3 = 1 then high ut10
    if portd.0 = 1 then high ut10
    if portd.1 = 1 then high ut10

    if portc.5 = 1 then high ut10
    if portc.4 = 1 then high ut10
    if portd.3 = 1 then high ut10
    if portd.2 = 1 then high ut10

    pause 1
    low ut10
    goto loop
    '---------------------------------




    link to my schematics:
    http://www.mediespecialist.se/pic16f874a/874a.gif
    and a picture:
    http://www.mediespecialist.se/pic16f874a/IMG_2144.JPG

    / Petter

Similar Threads

  1. Input problems with 12F629?
    By achilles03 in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 24th April 2018, 06:25
  2. 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
  3. Input problems
    By ALFRED in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 23rd July 2006, 21:02
  4. Problems with PORTD on 18F658
    By blainecf in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 13th June 2006, 17:32
  5. 18F6680 and portd problems.
    By jkbh in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 6th June 2005, 10:54

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