-
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
-
>>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.
-
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.
-
Have you set the TRISD register correctly?