Alternate Functions; Analog Configuration - ST STM32 Application Note

Microcontroller gpio hardware settings and low-power consumption
Hide thumbs Also See for STM32:
Table of Contents

Advertisement

GPIO functional description
4.3.3

Alternate functions

On some STM32 GPIO pins, the user has the possibility to select alternate functions
inputs / outputs. Each pin is multiplexed with up to sixteen peripheral functions such as
communication interfaces (SPI, UART, I
interface, and others.
The alternate function of the selected pin is configured through two registers:
GPIOx_AFRL (for pin 0 to 7)
GPIOx_AFRH (for pin 8 to 15)
To know which functions are multiplexed on each GPIO pin, refer to the device datasheet.
When the I/O port is programmed as alternate function mode:
The output buffer can be configured in open-drain or push-pull mode
The output buffer is driven by the signals coming from the peripheral (transmitter
enable and data)
The Schmitt trigger input is activated
The pull-up and pull-down resistors activations depend on the value in the register
GPIOx_PUPDR
The data present on the I/O pin are sampled into the input data register at each AHB clock
cycle.
A read access to the input data register provides the I/O state.
Alternate functions details are provided in the datasheet and the reference manual of the
product.
4.3.4

Analog configuration

Few STM32 GPIO pins can be configured in analog mode which allows the use of ADC,
DAC, OPAMP, and COMP internal peripherals. To use a GPIO pin in analog mode, the
following register are considered:
- GPIOx_MODER to select the mode (Input, Output, Alternate, Analog)
- GPIOx_ASCR to select the required function ADC, DAC, OPAMP, or COMP
When the I/O port is programmed in an analog configuration:
The output buffer is disabled
The Schmitt trigger input is deactivated, providing zero consumption for every analog
value of the I/O pin.The output of the Schmitt trigger is forced to a constant value (0).
The pull-up and pull-down resistors are disabled by hardware
Read access to the input data register gets the value 0.
For details concerning ADC, DAC, OPAMP and COMP function and programming, refer to
the datasheet and reference manual of the product.
The analog switch itself is not closed. The analog switch is closed only when analog
peripheral is selected (or enabled) on the given pin.
12/31
2
C, USB, CAN, LCD and others), timers, debug
AN4899 Rev 3
AN4899

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the STM32 and is the answer not in the manual?

Questions and answers

Table of Contents