CHAPTER 4 PORT FUNCTIONS
User’s Manual U16898EJ3V0UD
65
4.4 Operation of Port Function
The operation of a port differs, as follows, depending on the setting of the I/O mode.
Caution Although a 1-bit memory manipulation instruction manipulates 1 bit, it accesses a port in 8-bit
units. Therefore, the contents of the output latch of a pin in the input mode, even if it is not
subject to manipulation by the instruction, are undefined in a port with a mixture of inputs and
outputs.
4.4.1 Writing to I/O port
(1) In output mode
The data can be written to the output latch by a transfer instruction. In addition, the data of the output latch are
output from the pin. Once data is written to the output latch, it is retained until new data is written to the output
latch.
When a reset signal is generated, cleans the data in the output latch.
(2) In input mode
The data can be written to the output latch by a transfer instruction. Because the output buffer is off, however,
the pin status remains unchanged.
Once data is written to the output latch, it is retained until new data is written to the output latch.
When a reset signal is generated, cleans the data in the output latch.
4.4.2 Reading from I/O port
(1) In output mode
The data of the output latch can be read by a transfer instruction. The data of the output latch remain unchanged.
(2) In input mode
The pin status can be read by a transfer instruction. The contents of the output latch remain unchanged.
4.4.3 Operations on I/O port
(1) In output mode
An operation is performed on the data of the output latch. The result is written to the output latch. The data of the
output latch are output from the pin.
Once data is written to the output latch, it is retained until new data is written to the output latch.
When a reset signal is generated, cleans the data in the output latch.
(2) In input mode
The pin level is read and an operation is performed on its data. The operation result is written to the output latch.
However, the pin status remains unchanged because the output buffer is off.
When a reset signal is generated, cleans the data in the output latch.