Port Manipulation


Closed Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2005
    Posts
    74

    Default Port Manipulation

    I have a port which has the first 4 pins as inputs and the second 4 pins as outputs.
    Reading the inputs and the outputs is pretty easy as I just masked them such as:

    DigIn = (PortD & $F) 'Lower 4 bits
    DigOut = (PortD >> 4) 'Upper 4 bits

    Now I want to change the outputs, so say I write:
    NewOuts = 240
    PortD = NewOuts 'Turns on all the upper 4 bits.

    This works fine, but I think it's automatically turning my lower 4 pins into outputs?
    How is the best way to do this?

    PortD = PortD OR NewOuts

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


    Did you find this post helpful? Yes | No

    Default

    >>This works fine, but I think it's automatically turning my lower 4 pins into outputs?

    No - it does not affect the lower 4 pins if they are inputs ... the value on the inputs are what they are and not affected by the writes to the port. Writing to the port also does not affect the TRIS register unless you have errors in your code.
    Paul Borgmeier
    Salt Lake City, UT
    USA
    __________________

  3. #3
    Join Date
    Oct 2005
    Posts
    74


    Did you find this post helpful? Yes | No

    Default

    Yes, after trying numerous things by using bit logic and then setting the pin directly I still see the same problem.

    Each time I set mutiple outputs on PortD my inputs start changing. I noticed the LEDs on the EasyPic board are dimly lit. It's the way I'm using the protoboard and not the bitlogic I was using.

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    Have you set the TRISD register correctly?

Similar Threads

  1. Why (or how to) make a port array for OW
    By Roy___ in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 22nd February 2009, 23:30
  2. Change On Interrupt, PIC16F884
    By elec_mech in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 14th November 2008, 17:25
  3. port config.
    By tamertokgoz in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 25th July 2008, 12:25
  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. STATUS re-curtain W
    By zugvogel1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 13th February 2005, 15:21

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