General-Purpose Input/Output (GPIO)
353
SPRUH22I – April 2012 – Revised November 2019
Copyright © 2012–2019, Texas Instruments Incorporated
General-Purpose Input/Output (GPIO)
4.1.6.10 GPIO Alternate Function Select (GPIOAFSEL) Register, offset 0x420
The GPIOAFSEL register is the mode control select register. If a bit is clear, the pin is used as a GPIO
and is controlled by the GPIO registers. Setting a bit in this register configures the corresponding GPIO
line to be controlled by an associated peripheral. Several possible peripheral functions are multiplexed on
each GPIO. The GPIO Port Control (GPIOPCTL) register is used to select one of the possible functions.
NOTE:
All GPIO pins are configured as GPIOs and tri-stated by default (GPIOAFSEL=0,
GPIODEN=0, GPIOPUR=0, and GPIOPCTL=0. A Power-On-Reset POR or asserting XRS
puts the pins back to their default state.
CAUTION
It is possible to create a software sequence that prevents the debugger from
connecting to the microcontroller. If the program code loaded into flash
immediately changes the JTAG pins to their GPIO functionality, the debugger
may not have enough time to connect and halt the controller before the JTAG
pin functionality switches. As a result, the debugger may be locked out of the
part. This issue can be avoided with a software routine that restores JTAG
functionality based on an external or software trigger.
The GPIO commit control registers provide a layer of protection against accidental programming of critical
hardware peripherals. Protection is provided for the NMI pin (PB7). Writes to protected bits of the GPIO
Alternate Function Select (GPIOAFSEL) register, GPIO Pull Up Select (GPIOPUR) register, GPIO Core
Select (GPIOCSEL) register, and GPIO Digital Enable (GPIODEN) register are not committed to storage
unless the GPIO Lock (GPIOLOCK) register has been unlocked and the appropriate bits of the GPIO
Commit (GPIOCR) register have been set.
When using the I2C module, in addition to setting the GPIOAFSEL register bits for the I2C clock and data
pins, the pins should be set to open drain using the GPIO Open Drain Select (GPIOODR) register (see
examples in
Figure 4-13. GPIO Alternate Function Select (GPIOAFSEL) Register
31
16
Reserved
R-0
15
8
7
0
Reserved
AFSEL
R-0
R/W-0
LEGEND: R/W = Read/Write; R = Read only; -
n
= value after reset
Table 4-15. GPIO Alternate Function Select (GPIOAFSEL) Register Field Descriptions
Bit
Field
Value
Description
31-8
Reserved
Reserved
7-0
AFSEL
GPIO Alternate Function Select
0
The associated pin functions as a GPIO and is controlled by the GPIO registers.
1
The associated pin functions as a peripheral signal and is controlled by the alternate hardware
function.