Pseudoport with Pic

Thread Starter

PRS

Joined Aug 24, 2008
989
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.
 

thatoneguy

Joined Feb 19, 2009
6,359
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.
 

Markd77

Joined Sep 7, 2009
2,806
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.
 

spinnaker

Joined Oct 29, 2009
7,830
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.
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.
 
Top