
194
CHAPTER 8 I/O PORTS
8.7.2
Operation of Port 4
This section describes the operation of port 4.
s Operation of Port 4
r Setting Port 4 as an output port in the Port 4 direction register (DDR4)
The value stored in the Port 4 data register (PDR4) is output to the Port 4 pin.
If the PDR4 register is read, the value stored in PDR4 register is output.
r Setting Port 4 as an input port in the Port 4 direction register (DDR4)
The Port 4 pin has high impedance.
If the Port 4 data register (PDR4) is set to a value, the value stored in the PDR4 register is
retained but not output to the pin.
If the PDR4 register is read, the pin input level ("0" for "L" or "1" for "H") is output.
Note:
If a read-modify-write instruction (such as the bit set instruction) is used to access the PDR4
register, no bit specified for output in the DDR4 register is affected. For a bit specified for
input in the DDR4 register, however, the pin input level is written to the PDR4 register.
Therefore, to change a bit specified for input to output, first write an output value to the
PDR4 register and then specify the DDR4 register as an output port.
r Port operation for resource output
The resource output enable bit is set to enable the port to be used for resource output. The
state of the resource enable bit takes precedence when specifying a switch between input and
output. Even if a DDR4 register bit is 0, the corresponding port pin is used for resource output if
the resource has been enabled for output. If the DDR4 bit corresponding to the pin that can
also be used for resource output is set to "0", set the resource output to Enabled to read the out
put value of the resource.
r Port operation for resource input
To use for resource input the I/O port that can also be used for resource input, set the DDR4 bit
corresponding to the pin to "0".
r Port operation after a reset
When the CPU is reset, the DDR4 register is initialized to "00H" and the Port 4 pin has high
impedance.
The PDR4 register is not initialized when the CPU is reset. To use the PDR4 as an output
port, first write an output value to the PDR4 register and then specify the DDR4 register as
an output port.