This is an old revision of the document!


General Purpose Output

  • The output buffer is enabled (open drain or push-pull).
  • The Schmitt trigger input is active.
  • The pull-up and -down resistors are active, according to PUPDR.
  • Input data is sampled every AHB clock.
  • Input data register holds I/O state.
  • Output data register holds last written value.




Make sure the peripheral is enabled:

  • Enable GPIOx in RCC→AHBENR[0].

Configure the MODE and PUPDR as well as the output type and speed register,
for every pin that should act as digital output:

  • Write 0x01 to the corresponding fields in GPIOx→MODE.
  • Configure pull-up / -down in GPIOx→PUPDR.
  • Configure output type in GPIOx→OTYPER.
    (in conjunction with GPIOx→PUPDR)
  • Configure output speed in GPIOx→OSPEEDR.


Port mode register




Pin x01Output mode

Port pull-up / pull-down register




Pin x00No pull-up, pull-down (reset state)
01Pull-up
10Pull-down
11Reserved

Port output type register




Pin x0Output type: push-pull (reset state)
1Output type: open-drain

Port output speed register




Pin x00Speed: 2 MHz (reset state)
01Speed: 10 MHz
10Speed: 50 MHz
11Speed: 100 MHz

Port output data register




ODx0Clear/reset pin x
1Set pin x

Port bit set / reset register




BSx0No effect
1Set pin x
BRx0No effext
1Clear/reset pin x




  • stm32/peripherals/gpio_output.1672162548.txt.gz
  • Last modified: 2022/12/27 17:35
  • by ruan