Understanding GPIO Modes in STM32 Microcontrollers

GPIO_Mode_Out_PP Push-Pull Output Normal Digital Output

GPIO_Mode_Out_OD Open-Drain Output Level Conversion, Bus

GPIO_Mode_AF_PP Alternate Function Push-Pull SPI, USART, etc.

GPIO_Mode_AF_OD Alternate Function Open-Drain I2C, Multi-Master Bus

Alternate Functionality

· The pin is no longer used as a regular GPIO

· Instead, it is connected to specific peripherals inside the chip (such as USART, SPI, I2C, TIM, etc.)

· The function of the pin is controlled by the corresponding peripheral

Open-Drain Output

· The output circuit only has a pull-down MOSFET, with no pull-up MOSFET

· Output characteristics:

· Can actively pull the level low (output 0)

· Cannot actively output a high level, requires an external pull-up resistor

· In high level, it presents a high-impedance state

Leave a Comment