CHAPTER 5 PORT FUNCTIONS
User’s Manual U15109EJ3V0UD
198
5.4
Operation of Port Function
The operation of a port differs depending on whether the port is in the input or output mode, as described below.
5.4.1 Writing data to I/O port
(1) In output mode
A value can be written to the output latch by using a transfer instruction. The contents of the output latch are
output from the pin. Once data has been written to the output latch, it is retained until new data is written to the
output latch.
(2) In input mode
A value can be written to the output latch by using a transfer instruction. Because the output buffer is off,
however, the status of the pin does not change.
Once data has been written to the output latch, it is retained until new data is written to the output latch.
Caution
A bit manipulation instruction (CLR1, SET1, NOT1) manipulates 1 bit but accesses a port in 8-
bit units. If this instruction is executed to manipulate a port with a mixture of input and output
bits, the contents of the output latch of a pin set in the input mode, in addition to the bit to be
manipulated, are overwritten to the current input pin status and become undefined.
5.4.2 Reading data from I/O port
(1) In output mode
The contents of the output latch can be read by using a transfer instruction. The contents of the output latch do
not change.
(2) In input mode
The status of the pin can be read by using a transfer instruction. The contents of the output latch do not change.