2.3 Parallel Ports
76
Chapter 2: Hardware Configuration
[CAUTION]
When the above registers are accessed using read-modify-write instructions (such as bit
set instructions), the targeted bit in the command will be set to the designated value, how-
ever for any other bits set for input the designated input value of the signal pin will be
overwritten with the contents of the corresponding output register. For this reason, when-
ever pins used for input are switched to output, it is first necessary to write the desired val-
ues in the PDR register before setting the DDR register to switch to output.
[CAUTION]
The process of reading and writing to I/O ports differs from reading and writing to mem-
ory 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]
Note that read/write operations for port 6 differ from those for other ports.
Port 6 (P67, P66, P63 to P60) is an open-drain type general-purpose I/O port which is designed to also
function as an analog input signal port. When used as a general-purpose port, the bit(s) corresponding
to the ADER register must be set to '0.'
When used as an input port, the contents of the output data register should be set to 'ALL 1' in order to
turn off all open-drain output transistors, and external pull-up resistor should be connected. 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 and forcibly
driven to ',0' there should be no change, even to contents of pins 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 correspond-
ing output data register.
Also, bits set to '1' in the analog input enable register will always produce the value '0' when read from
the corresponding signal pin.