Hi.
The P3 I/O port in my application has some bits used for output-only and some for input-only. The output-only bits are configured in push-pull mode and the input-only ones in quasi-bidirectional.
In quasi-bidirectional mode I have to write a '1' to the bit latch, so as to not pull the line down myself.
My question: Can I use bit set/bit clear instructions (CLR, SETB) on the output-only bits without clobbering the bit-latch for the input bit?
If SETB/CLR are implemented as RMW, and the input value is zero, that will clobber the latch, but if the SFR is truly bit-addressable at the lowest level, then a bit operation won't clobber neighboring bits.
Here's an example to clarify my question:
Suppose bit-7 is my input pin and bit 0 is my output pin.
I want to set the output latch on bit 7 to '1' so as to allow the external device to drive it. I can do this with the instruction:
setb P3.7
If the device is currently driving the pin low, I'll get a zero in bit-7 if I read P3 back.
Now say I want to drive out a '1' on my output bit, bit 0. I *could* do this with:
setb P3.0
But if this is implemented internally as a read-modify-write, it could do:
P3