8.
Program each pad in the port to have either pull-up, pull-down, or open drain functionality through
the
GPIOPUR
,
GPIOPDR
,
GPIOODR
register. Slew rate may also be programmed, if needed,
through the
GPIOSLR
register.
9.
To enable GPIO pins as digital I/Os, set the appropriate
DEN
bit in the
GPIODEN
register. To
enable GPIO pins to their analog function (if available), set the
GPIOAMSEL
bit in the
GPIOAMSEL
register.
10.
Program the
GPIOIS
,
GPIOIBE
,
GPIOEV
, and
GPIOIM
registers to configure the type, event,
and mask of the interrupts for each port.
Note:
To prevent false interrupts, the following steps should be taken when re-configuring
GPIO edge and interrupt sense registers:
a.
Mask the corresponding port by clearing the
IME
field in the
GPIOIM
register.
b.
Configure the
IS
field in the
GPIOIS
register and the
IBE
field in the
GPIOIBE
register.
c.
Clear the
GPIORIS
register.
d.
Unmask the port by setting the
IME
field in the
GPIOIM
register.
11.
Optionally, software can lock the configurations of the NMI and JTAG/SWD pins on the GPIO
port pins, by setting the
LOCK
bits in the
GPIOLOCK
register.
When the internal POR signal is asserted and until otherwise configured, all GPIO pins are configured
to be undriven (tristate):
GPIOAFSEL
=0,
GPIODEN
=0,
GPIOPDR
=0, and
GPIOPUR
10-4 on page 754 shows all possible configurations of the GPIO pads and the control register settings
required to achieve them. Table 10-5 on page 755 shows how a rising edge interrupt is configured
for pin 2 of a GPIO port.
Table 10-4. GPIO Pad Configuration Examples
GPIO Register Bit Value
a
Configuration
SLR
DR12R
DR8R
DR4R
DR2R
PDR
PUR
DEN
ODR
DIR
AFSEL
X
X
X
X
X
?
?
1
0
0
0
Digital Input
(GPIO)
?
?
?
?
?
?
?
1
0
1
0
Digital Output
(GPIO)
?
?
?
?
?
X
X
1
1
1
0
Open Drain Output
(GPIO)
?
?
?
?
?
X
X
1
1
X
1
Open Drain
Input/Output
(
I2CSDA
)
?
?
?
?
?
X
X
1
0
X
1
Digital Input/Output
(
I2CSCL
)
X
X
X
X
X
?
?
1
0
X
1
Digital Input (Timer
CCP)
X
X
X
X
X
?
?
1
0
X
1
Digital Input (QEI)
?
?
?
?
?
?
?
1
0
X
1
Digital Output
(PWM)
?
?
?
?
?
?
?
1
0
X
1
Digital Output
(Timer PWM)
June 18, 2014
754
Texas Instruments-Production Data
General-Purpose Input/Outputs (GPIOs)