RL78/G1P
CHAPTER 4 PORT FUNCTIONS
R01UH0895EJ0100 Rev.1.00
70
Nov 29, 2019
4.2.2 Port 2
Port 2 is an I/O port with an output latch. Port 2 can be set to the input mode or output mode in 1-bit units using port
mode register 2 (PM2).
This port can also be used for A/D converter analog input, (+ side and – side) reference voltage input, and D/A
converter output.
To use P20/ANI0, P21/ANI1, P22/ANI2/ANO0, P23/ANI3/ANO1, P24/ANI4 to P27/ANI7 as digital input pins or digital
output pins, use these pins as following order.
P27
P26
P25
P21
P20
P22
P23
P24
To use P20 and P21 as A/D converter analog input and (+ side and – side) reference voltage input when P20/ANI0,
P21/ANI1, P22/ANI2/ANO0, P23/ANI3/ANO1, P24/ANI4 to P27/ANI7 is used as analog I/O pins, use these pins starting
from the next pin of P20 or P21.
In other case, use these pins as following order.
P24
P23
P22
P20
P21
P25
P26
P27
Table 4-3. Settings of Registers When Using Port 2
Name
I/O
PM2n
ADPC
Alternate Function Setting
Remark
P2n
Input 1 1
To use P2n as a port, use these
pins from a higher bit.
Output 0 1
Remarks 1.
PM2
: Port mode register 2
ADPC: A/D port configuration register
2.
n = 0 to 7
Table 4-4. Setting Functions of P20/ANI0, P21/ANI1, P24/ANI4 to P27/ANI7 Pins
ADPC Register
PM2 Register
ADS Register
P20/ANI0, P21/ANI1,
P24/ANI4 to P27/ANI7 Pins
Digital I/O selection
Input mode
Digital input
Output mode
Digital output
Analog input selection
Input mode
Selects ANI.
Analog input (to be converted)
Does not select ANI.
Analog input (not to be converted)
Output mode
Selects ANI.
Setting prohibited
Does not select ANI.
P20/ANI0, P21/ANI1, P24/ANI4 toP27/ANI7 are set in the analog input mode when the reset signal is generated.