
RM0008
General-purpose and alternate-function I/Os (GPIOs and AFIOs)
Doc ID 13902 Rev 12
157/1096
or for reset only GPIOx_BRR) to select the bits you want to modify. The unselected bits will
not be modified.
9.1.3 External
interrupt/wakeup lines
All ports have external interrupt capability. To use external interrupt lines, the port must be
configured in input mode. For more information on external interrupts, refer to:
●
Section 10.2: External interrupt/event controller (EXTI) on page 197
and
●
Section 10.2.3: Wakeup event management on page 198
9.1.4
Alternate functions (AF)
It is necessary to program the Port Bit Configuration Register before using a default
alternate function.
●
For alternate function inputs, the port must be configured in Input mode (floating, pull-
up or pull-down) and the input pin must be driven externally.
Note:
It is also possible to emulate the AFI input pin by software by programming the GPIO
controller. In this case, the port should be configured in Alternate Function Output mode.
And obviously, the corresponding port should not be driven externally as it will be driven by
the software using the GPIO controller.
●
For alternate function outputs, the port must be configured in Alternate Function Output
mode (Push-Pull or Open-Drain).
●
For bidirectional Alternate Functions, the port bit must be configured in Alternate
Function Output mode (Push-Pull or Open-Drain). In this case the input driver is
configured in input floating mode
If you configure a port bit as Alternate Function Output, this disconnects the output register
and connects the pin to the output signal of an on-chip peripheral.
If software configures a GPIO pin as Alternate Function Output, but peripheral is not
activated, its output is not specified.
9.1.5
Software remapping of I/O alternate functions
To optimize the number of peripheral I/O functions for different device packages, it is
possible to remap some alternate functions to some other pins. This is achieved by
software, by programming the corresponding registers (refer to
In that case, the alternate functions are no longer mapped to their original assignations.
9.1.6 GPIO
locking
mechanism
The locking mechanism allows the IO configuration to be frozen. When the LOCK sequence
has been applied on a port bit, it is no longer possible to modify the value of the port bit until
the next reset.