Rev.1.00
May 18, 2004
page 231 of 296
M306V7MG/MH/MJ/MJA-XXXFP, M306V7FG/FH/FJ/FJAFP
2.17 Programmable I/O Ports
There are 76 programmable I/O ports: P0–P5, P60–P63, P67, P7, P82, P83, P86, P87, P90–P94, P102–
P107. Each port can be set independently for input or output using the direction register. A pull-up resis-
tance for each block of 4 ports can be set.
Figures 2.17.1 to 2.17.4 show the programmable I/O ports.
Each pin functions as a programmable I/O port and as the I/O for the built-in peripheral devices.
To use the pins as the inputs for the built-in peripheral devices, set the direction register of each pin to input
mode. When the pins are used as the outputs for the built-in peripheral devices (other than the D-A con-
verter), they function as outputs regardless of the contents of the direction registers. When pins are to be
used as the outputs for the D-A converter, do not set the direction registers to output mode. See the
descriptions of the respective functions for how to set up the built-in peripheral devices.
2.17.1 Direction Registers
Figures 2.17.6 to 2.17.10 show the direction registers.
These registers are used to choose the direction of the programmable I/O ports. Each bit in these regis-
ters corresponds one for one to each I/O pin.
(1) Effect of the protection register
Data written to the direction register of P9 is affected by the protection register. The direction register
of P9 cannot be easily written.
2.17.2 Port Registers
Figures 2.17.11 to 2.17.15 show the port registers.
These registers are used to write and read data for input and output to and from an external device. A
port register consists of a port latch to hold output data and a circuit to read the status of a pin. Each bit
in port registers corresponds one for one to each I/O pin.
(1) Reading a port register
With the direction register set to output, reading a port register takes out the content of the port regis-
ter, not the content of the pin. With the direction register set to input, reading the port register takes out
the content of the pin.
(2) Writing to a port register
With the direction register set to output, the level of the written values from each relevant pin is output
by writing to a port register. Writing to the port register, with the direction register set to input, inputs a
value to the port register, but nothing is output to the relevant pins. The output level remains floating.