General Purpose Output




Programming Instructions

Enable Peripheral

Make sure the peripheral is enabled:

Setup output mode

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


Configuration Registers

GPIOx_MODER - Port mode register




Pin x01Output mode

GPIOx_PUPDR - Port pull-up / pull-down register




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

GPIOx_OTYPER - Port output type register




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

GPIOx_OSPEEDR - Port output speed register




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

Data Registers

GPIOx_ODR - Port output data register




ODx0Clear/reset pin x
1Set pin x

GPIOx_BSRR Port bit set / reset register




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