Pseudoport with Pic

Discussion in 'Embedded Systems and Microcontrollers' started by PRS, Nov 27, 2010.

  1. PRS

    Thread Starter Well-Known Member

    Aug 24, 2008
    I need to turn 4 bits of port B and 4 bits of port A into a single byte, such that I create a byte-oriented data port for IO. Is this possible?

    And how do I set up port B for IO such that I leave B7, B6, and B5 alone. The upper bits of port B is how PICKit3 converses with the host computer, and I don't want to upset that, though I need the lower 4 bits.
  2. thatoneguy

    AAC Fanatic!

    Feb 19, 2009
    Are you trying to make it so you can do a PORT++ or similar operation on the 8 I/O lines?

    if so, you could use a global variable, and a routine to call that "breaks up" the variable and writes it to the correct I/O.
  3. Markd77

    Senior Member

    Sep 7, 2009
    I'd have thought you just set them to input. Then you can just ignore them.
    In assembler the swap instruction swaps the 2 halves of a byte so it can be done very cheaply, not sure what the C for swap is.
  4. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    I think you are going to have to read each bit in dependently and combine them into a single variable using shifting as you read each bit.