
173
8.3 Port 0
8.3.2
Operation of Port 0
This section describes the operation of port 0.
s Operation of Port 0
r Setting Port 0 as an output port in the Port 0 direction register (DDR0)
The value stored in the Port 0 data register (PDR0) is output to the Port 0 pin.
If the PDR0 register is read, the value stored in the PDR0 register is output.
r Setting Port 0 as an input port in the Port 0 direction register (DDR0)
The Port 0 pin has high impedance. However, the Port 0 pin retains the "H" level if the bit in
the Port 0 pull-up resistor register (RDR0) is set to "1" and thus the pull-up resistor is
connected.
If the Port 0 data register (PDR0) is set to a value, the value stored in the PDR0 register is
retained but not output to the pin.
If the PDR0 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 PDR0
register, no bit specified for output in the DDR0 register is affected. For a bit specified for
input in the DDR0 register, however, the pin input level is written to the PDR0 register.
Therefore, to change a bit specified for input to output, first write an output value to the
PDR0 register and then specify the DDR0 register as an output port.
r Port operation after a reset
When the CPU is reset, the DDR0 and RDR0 registers are initialized to "00H" and the Port 0
pin has high impedance.
The PDR0 register is not initialized when the CPU is reset. To use the PDR0 as an output
port, first write an output value to the PDR0 register and then specify the DDR0 register as
an output port.