CHAPTER 5 PORT FUNCTIONS
User’s Manual U15109EJ3V0UD
150
(1) Function of P2 pins
Port 2 is an 8-bit I/O port for which I/O settings can be controlled in 1-bit units. I/O settings are controlled via the
port 2 mode register (PM2).
In output mode, the values set to each bit are output to port 2 (P2). Also, P20 and P22 are selectable as normal
outputs or N-ch open-drain outputs using the port 2 function register (PF2).
When using this port in input mode, the pin statuses can be read by reading P2. Also, the values of P2 (output
latch) can be read by reading P2 while in output mode.
Clear P2 and the PM2 register to 0 when using alternate-function pins as outputs. The logical sum (ORed result)
of the port output and the alternate-function pin is output from the pins.
When a reset is input, the settings are initialized to input mode.
(2) Control registers
(a) Port 2 mode register (PM2)
PM2 can be read/written in 8- or 1-bit units.
After reset:
FFH
R/W
Address: FFFFF024H
7
6
5
4
3
2
1
0
PM2
PM27
PM26
PM25
PM24
PM23
PM22
PM21
PM20
PM2n
Control of I/O mode (n = 0 to 7)
0
Output mode
1
Input mode
(b) Port 2 function register (PF2)
PF2 can be read/written in 8- or 1-bit units.
After reset:
00H
R/W
Address: FFFFF0A4H
7
6
5
4
3
2
1
0
PF2
0
0
0
0
0
PF22
0
PF20
PF2n
Control of normal output/N-ch open-drain output (n = 0, 2)
0
Normal output
1
N-ch open-drain output