0% found this document useful (0 votes)
115 views5 pages

STM32 General Purpose Input Output

STM32 GPIO ports can be configured in several modes including input, output, input/output, and external interrupt. Input modes include floating, pull-up, and pull-down. Output modes include open-drain and push-pull. Alternate function modes multiplex pins for peripherals. Speed and edge detection can also be configured.

Uploaded by

Marwen Ouled Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
115 views5 pages

STM32 General Purpose Input Output

STM32 GPIO ports can be configured in several modes including input, output, input/output, and external interrupt. Input modes include floating, pull-up, and pull-down. Output modes include open-drain and push-pull. Alternate function modes multiplex pins for peripherals. Speed and edge detection can also be configured.

Uploaded by

Marwen Ouled Ali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

STM32 General Purpose Input Output (GPIO)

GPIO Modes

GPIO ports can be individually configured by software in several modes:


1. Input:
➢ Input floating
➢ Input pull-up
➢ Input-pull-down
2. Output:
➢ Output open-drain with pull-up or pull-down capability
➢ Output push-pull with pull-up or pull-down capability
3. Input/Output:
➢ Analog
➢ Alternate function push-pull with pull-up or pull-down capability
➢ Alternate function open-drain with pull-up or pull-down capability
In addition to standard GPIO modes, the pin mode can be configured as EXTI (Extended interrupt
and event controller) with interrupt.
4. External Interrupt mode:
➢ GPIO_MODE_IT_RISING : Rising edge trigger detection
➢ GPIO_MODE_IT_FALLING : Falling edge trigger detection
➢ GPIO_MODE_IT_RISING_FALLING : Rising/Falling edge trigger detection
Another variable to be considered is the speed (this controls the slew rate (the rise time and fall
time) of the output signal). Possible values are:
➢ GPIO_SPEED_FREQ_LOW
➢ GPIO_SPEED_FREQ_MEDIU
➢ GPIO_SPEED_FREQ_HIGH
➢ GPIO_SPEED_FREQ_VERY_HIGH

Detailed explanation ofGPIO Modes

1. Input Configuration
When the I/O port is programmed as input:
(1) The output buffer is disabled (open circuit)
(2) The Schmitt trigger input is activated
(3) The pull-up and pull-down resistors are activated by programming
(4) The data present on the I/O pin are sampled into the input data register
(5) A read access to the input data register provides the I/O state

Floating Input: Its state is indeterminate, meaning that it is neither connected to VCC or to ground.
It’s used interchangeably to describe a pin which is in the high-impedance state
pull-up Input: Pull-up resistor is used to set a pin to a logical high state ( 30 k Ω≤RPU ≤50 k Ω )
pull-down Input: Pull-down resistor is used to set a pin to a logical low state
( 30 k Ω≤RPD≤50 k Ω )

2. Output configuration

When the I/O port is programmed as output:


(1) The output buffer is enabled:
✔ Open drain mode: A “0” in the Output register activates the N-MOS whereas a “1” in the
Output register leaves the port in Hi-Z (the P-MOS is never activated)
✔ Push-pull mode: A “0” in the Output register activates the N-MOS whereas a “1” in the
Output register activates the P-MOS
(2) The Schmitt trigger input is activated
(3) The pull-up and pull-down resistors are activated by programming
(4) The data present on the I/O pin are sampled into the input data register
(5) A read access to the input data register gets the I/O state
(6) A read access to the output data register gets the last written value

Output Push Pull: In Push-Pull type there will be two switches (transistor/ MOSFET) inside the
micro-controller and one switch will be connected to Ground and the other will be connected to
Vcc/Vdd. If you make the output HIGH the pin will be connected to Vdd through the NPN switch
and if you make the Output pin LOW the pin will be connected to Ground thorough the PNP switch
Output Open Drain: There will be only one switch (transistor/MOSFET) inside the uC and this
switch is connected to Ground. If you make the output pin HIGH the pin will be connected to
ground through the switch and if you make the Output pin LOW the pin will be left floating since
the switch will be turned off. Since in the Open Drain type the pin is left as floating a pull-high or
pull-down resistor is usually added to the GPIO pin

3. Alternate function configuration


On some 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,
I2C, USB, CAN, LCD and others), timers, debug interface, and others
When the I/O port is programmed as alternate function:
(1) The output buffer can be configured in open-drain or push-pull mode
(2) The output buffer is driven by the signals coming from the peripheral (transmitter enable
and data)
(3) The Schmitt trigger input is activated
(4) The weak pull-up and pull-down resistors are activated or not by programming
(5) The data present on the I/O pin are sampled into the input data register
(6) A read access to the input data register gets the I/O state
4. Analog configuration
Analog mode allows the use of ADC, DAC, OPAMP, and COMP internal peripherals.
When the I/O port is programmed as analog configuration:
(1) The output buffer is disabled
(2) 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).
(3) The weak pull-up and pull-down resistors are disabled by hardware
(4) Read access to the input data register gets the value “0”

You might also like