
200
CHAPTER 8 I/O PORTS
8.8.2
Operation of Port 5
This section describes the operation of port 5.
s Operation of Port 5
r Setting Port 5 as an output port in the Port 5 direction register (DDR5) and the analog
input enable register (ADER)
The value stored in the Port 5 data register (PDR5) is output to the Port 5 pin.
If the PDR5 register is read, the value stored in PDR5 register is output.
r Setting Port 5 as an input port in the Port 5 direction register (DDR5) and the analog input
enable register (ADER)
The Port 5 pin has high impedance.
If the Port 5 data register (PDR5) is set to a value, the value stored in the PDR5 register is
retained but not output to the pin.
If the PDR5 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 PDR5
register, no bit specified for output in the DDR5 register is affected. For a bit specified for
input in the DDR5 register, however, the pin input level is written to the PDR5 register.
Therefore, to change a bit specified for input to output, first write an output value to the
PDR5 register and then specify the DDR5 register as an output port.
r Setting Port 5 as analog input of the A/D converter
To use a port pin as analog input of the A/D converter, set the bit of the ADER register
corresponding to the analog input pin of the A/D converter to "1". If a pin is set for analog input
of the A/D converter, read a corresponding bit of the PDR5 register to obtain the read value of
"0".
r Port operation as resource output
To use a port pin as resource output, set the bit of the ADER register corresponding to the
resource output pin to "0" and the output enable bit of the resource to be used to Enabled.
Even if a pin that also serves as the DDR5 resource pin is set to "0", the resource can be output
as long as the resource output is enabled because resource output gets higher priority than port
output. If a pin that also serves as the DDR5 resource pin is set to "0", enable the resource
output to read the output value of the resource.
r Port operation as resource input
To use for resource input the I/O port pin that can also be used for resource input, set the
corresponding bit of the ADER register to "0" and the corresponding bit of the DDR5 register to
"0".