
CHAPTER 4 PORT FUNCTIONS
User’s Manual U17854EJ9V0UD
107
4.2.3 Port 2
Port 2 is an 8-bit 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.
To use P20/ANI0 to P27/ANI7 as digital input pins, set them in the digital I/O mode by using the A/D port
configuration register (ADPC) and in the input mode by using PM2. Use these pins starting from the lower bit.
To use P20/ANI0 to P27/ANI7 as digital output pins, set them in the digital I/O mode by using ADPC and in the
output mode by using PM2.
To use P20/ANI0 to P27/ANI7 as analog input pins, set them in the analog input mode by using the A/D port
configuration register (ADPC) and in the input mode by using PM2. Use these pins starting from the upper bit.
Table 4-4. Setting Functions of P20/ANI0 to P27/ANI7 Pins
ADPC
PM2
ADS
P20/ANI0 to P27/ANI7 Pins
Input mode
Digital input
Digital I/O selection
Output mode
Digital output
Selects ANI.
Analog input (to be converted)
Input mode
Does not select ANI.
Analog input (not to be converted)
Selects ANI.
Analog input selection
Output mode
Does not select ANI.
Setting prohibited
All P20/ANI0 to P27/ANI7 are set in the digital input mode when the reset signal is generated.
Figure 4-12 shows a block diagram of port 2.
Caution
See 2.2.12 AVREF for the voltage to be applied to the AVREF pin when using port 2 as a digital I/O.