
2.3 Parallel Ports
68
Chapter 2: Hardware
[CAUTION]
The process of reading from and writing to I/O ports differs from reading from and
writing to memory in the following ways.
Input Mode
Reading:
The read value is the signal level of the corresponding pin.
Writing:
The write data is stored in the output latch, and cannot be output to the pin.
Output Mode
Reading:
The read value is the value stored in the PDR register.
Writing:
The write data is stored in the output latch, and can also be output to the pin.
[CAUTION]
Port 4 pins 7 to 4 are input-only pins, and can only be used to read the incoming signal
level.
[CAUTION]
Note also that read/write operations for ports 4 and 5 differ from those for other ports.
Port 5 (P57 to P50) is an open-drain type general-purpose I/O port which is designed to also function as
an analog input signal pin. When used as a general-purpose port, the bit(s) corresponding to the ADER
register must be set to ‘0.’
When port 5 is used as an input port, the entire contents of the output data register must be set to ‘1’ in
order to turn off all open-drain output transistors, and external pull-up resistor must be mounted. Also,
for read access, one of the following two operations should be followed depending on the instruction
used.
When reading using read-modify-write instructions
Read the contents of the output data register. Even when each pin is externally driven to ‘0’
there should be no change, even to contents of bit(s) not designated by the instruction.
For reading using all other instructions
The level of each signal pin can be read.
When used as an output port, pin values can be changed by writing the desired value to the
corresponding output data register.
Also, the pin corresponding to the bits set to ‘1’ in the analog input enable register allows the data ‘0’ to
be read.