INPUT/OUTPUT PINS
7902 Group User’s Manual
6-4
6.2 Programmable I/O ports
6.2.2 Port register
Data is input from or output to the external by writing/reading data to/from a port register. A port register
consists of a port latch which holds the output data and a circuit which reads the pin state. One bit of the
port register corresponds to one pin of the microcomputer. (This is the one-to-one relationship.) Figure
6.2.3 shows the structure of the port Pi (i = 0 to 8, 10, 11) register.
q When outputting data from programmable I/O port which has been set to output mode
By writing data to the corresponding bit of the port register, the data is written into the port latch.
The data is output from the pin according to the contents of the port latch.
By reading the port register of a port which has been set to the output mode, the contents of the port
latch is read out, instead of the pin state. Accordingly, the output data can be correctly read out without
being affected by an external load, etc. (Refer to “Figures 6.2.4 and 6.2.5.”)
q When inputting data from programmable I/O port which has been set to input mode
A pin which has been set to the input mode enters the floating state.
By reading the corresponding bit of the port register, the data which has been input from the pin can
be read out.
By writing data to a port register of a programmable I/O port which has been set to the input mode,
the data is written only into the port latch and is not output to the external (Note). This pin remains
floating state.
Note: When executing a read-modify-write instruction to a port register of a programmable I/O port
which has been set to the input mode, the instruction will be executed to the data which has
been input from the pin and the result will be written into the port register.
6.2 Programmable I/O ports
Fig. 6.2.3 Structure of port Pi (i = 0 to 8, 10, 11) register
Port Pi register (i = 0 to 8, 10, 11)
(Addresses 216, 316, 616, 716, A16, B16, E16, F16, 1216, 1616, 1716)
b7 b6 b5 b4 b3 b2 b1 b0
RW
Bit name
Bit
0
1
2
3
4
5
6
7
Funtion
At reset
R/W
Pin port Pi0
Pin port Pi1
Pin port Pi2
Pin port Pi3
Pin port Pi4
Pin port Pi5
Pin port Pi6
Pin port Pi7
Undefined
Note: Nothing is assigned for bits 4 to 7 of the port P3 register. These bits are “0” at reading.
Data is input from or output to a pin by reading from
or writing to the corresponding bit.
0 : “L” level
1 : “H” level