7 I/O PORTS (PPORT)
S1C31D50/D51 TECHNICAL MANUAL
Seiko Epson Corporation
7-5
(Rev. 2.00)
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 PPORTP
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 PPORTP
x
CHATEN.P
x
CHATEN
y
bit to 1. *
When the chattering filter is not used, set the PPORTP
x
CHATEN.P
x
CHATEN
y
bit to 0 (supply of the
PPORT operating clock is not required).
3. Configure the following PPORTP
x
RCTL register bits when pulling up/down the port using the internal
pull-up or down resistor:
- PPORTP
x
RCTL.P
x
PDPU
y
bit
(Select pull-up or pull-down resistor)
- Set the PPORTP
x
RCTL.P
x
REN
y
bit to 1.
(Enable pull-up/down)
Set the PPORTP
x
RCTL.P
x
REN
y
bit to 0 if the internal pull-up/down resistors are not used.
4. Set the PPORTP
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 PPORTP
x
INTF.P
x
IF
y
bit.
(Clear interrupt flag)
- PPORTP
x
INTCTL.P
x
EDGE
y
bit
(Select interrupt edge (input rising edge/falling edge))
- Set the PPORTP
x
INTCTL.P
x
IE
y
bit to 1.
(Enable interrupt)
6. Set the following PPORTP
x
IOEN register bits:
- Set the PPORTP
x
IOEN.P
x
OEN
y
bit to 0.
(Disable output)
- Set the PPORTP
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 7.4.1.1 lists the port status according to the combination of data input/output control and pull-up/down
control.
Table 7.4.1.1 GPIO Port Control List
PPORTPxIOEN.
PxIENy bit
PPORTPxIOEN.
PxOENy bit
PPORTPxRCTL.
PxRENy bit
PPORTPxRCTL.
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 PPORTPxMODSEL.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 always read out as 0.
7.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.