IV - 25
Chapter 4
I/O Ports
Port 4
4-6
Port 4
nGeneral Port Setup
Each bit can be set individually to either an input or output by the port 4 I/O direction control register
(P4DIR). The control flag of the port 4 direction control register (P4DIR) is set to"1" for output mode, and
"0" for input mode.
To read input data of pin, set the control flag of the port 4 direction control register (P4DIR) to "0" and
read the value of the port 4 input register (P4IN).
To output data to pin, set the control flag of the port 4 direction control register (P4DIR) to "1" and write
data to the port 4 output register (P4OUT).
Each bit can be set individually if pull-up resistor is added or not, by the port 4 pull-up resistor control
register (P4PLU). Set the control flag of the port 4 pull-up resistor control register (P4PLU) to "1" to add
pull-up resistor.
nSpecial Function Pin Setup
P40 to P47 are used as input pins for KEY interrupt, as well.
Each bit can be set individually to synchronous output by the port 4 synchronous output control register
(P4SYO). The port 4 synchronous output control register (P4SYO) is set to "1" for synchronous output,
and "0" for general port. The pin control register (FLOAT) can select the event that generates
synchronous output. When the bp1, bp0 of the pin control register (FLOAT) is "00", the external interrupt
2 (IRQ2) is selected. And "01" for the timer 7 interrupt, "10" for the timer 2 interrupt, "11" for the timer 1
interrupt. For further detail, refer to 4-12. Synchronous output function [p.IV-50].
P40 to P47 can be used as the LCD segment output pin. Set "1" to bits 0 to 7 (LC2SL0 to LC2SL7) of the
LCD output control register 2 (LCCTR2) to use SEG24 to SEG31 pins. The port and segment pins can
be set by 1-bit. When segment output is selected, input mode is set and the pull-up resistor is unset
automatically.
4-6-1
Description
[
Chapter 3 3-3-6. Key Input Interrupt ]
[
Chapter 3 Fig. 3-3-3. Block Diagram, Fig. 3-3-6. Control Registers ]