6 I/O PORTS (PPORT)
S1C17M20/M21/M22/M23/M24/M25
Seiko Epson Corporation
6-5
TECHNICAL MANUAL (Rev. 1.0)
Initial settings when using a port as a general-purpose input port
(only for the ports with GPIO function)
When using the P
xy
port pin as a general-purpose input pin, perform the following software initial settings:
1. Write 0 to the P
x
INTCTL.P
x
IE
y
bit. * (Disable interrupt)
2. When using the chattering filter, configure the PPORT operating clock (see “PPORT Operating Clock”) and
set the P
x
CHATEN.P
x
CHATEN
y
bit to 1. *
When the chattering filter is not used, set the P
x
CHATEN.P
x
CHATEN
y
bit to 0 (supply of the PPORT op-
erating clock is not required).
3. Configure the following P
x
RCTL register bits when pulling up/down the port using the internal pull-up or
down resistor:
- P
x
RCTL.P
x
PDPU
y
bit
(Select pull-up or pull-down resistor)
- Set the P
x
RCTL.P
x
REN
y
bit to 1. (Enable pull-up/down)
Set the P
x
RCTL.P
x
REN
y
bit to 0 if the internal pull-up/down resistors are not used.
4. Set the P
x
MODSEL.P
x
SEL
y
bit to 0. (Enable GPIO function)
5. Configure the following bits when using the port input interrupt: *
- Write 1 to the P
x
INTF.P
x
IF
y
bit.
(Clear interrupt flag)
- P
x
INTCTL.P
x
EDGE
y
bit
(Select interrupt edge (input rising edge/falling edge))
- Set the P
x
INTCTL.P
x
IE
y
bit to 1. (Enable interrupt)
6. Set the following P
x
IOEN register bits:
- Set the P
x
IOEN.P
x
OEN
y
bit to 0. (Disable output)
- Set the P
x
IOEN.P
x
IEN
y
bit to 1.
(Enable input)
*
Steps 1 and 5 are required for the ports with an interrupt function. Step 2 is required for the ports with a chat-
tering filter function.
Table 6.4.1.1 lists the port status according to the combination of data input/output control and pull-up/down
control.
Table 6.4.1.1 GPIO Port Control List
PxIOEN.
PxIENy bit
PxIOEN.
PxOENy bit
PxRCTL.
PxRENy bit
PxRCTL.
PxPDPUy bit
Input
Output
Pull-up/pull-down
condition
0
0
0
×
Disabled
Off (Hi-Z)
*
1
0
0
1
0
Disabled
Pulled down
0
0
1
1
Disabled
Pulled up
1
0
0
×
Enabled
Disabled
Off (Hi-Z)
*
2
1
0
1
0
Enabled
Disabled
Pulled down
1
0
1
1
Enabled
Disabled
Pulled up
0
1
0
×
Disabled
Enabled
Off
0
1
1
0
Disabled
Enabled
Off
0
1
1
1
Disabled
Enabled
Off
1
1
1
0
Enabled
Enabled
Off
1
1
1
1
Enabled
Enabled
Off
*
1: Initial status. Current does not flow if the pin is placed into floating status.
*
2: Use of the pull-up or pull-down function is recommended, as undesired current will flow if the port input is set to floating status.
Note: If the PxMODSEL.PxSELy bit for the port without a GPIO function is set to 0, the port goes into
initial status (refer to “Initial Settings”). The GPIO control bits are configured to a read-only bit al-
ways read out as 0.
6.4.2 Port Input/Output Control
Peripheral I/O function control
The port for which a peripheral I/O function is selected is controlled by the peripheral circuit. For more infor-
mation, refer to the respective peripheral circuit chapter.