Contents RM0453
14/1450 RM0453 Rev 5
10 General-purpose I/Os (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
10.1 GPIO introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
10.2 GPIO main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
10.3 GPIO functional description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 400
10.3.1 General purpose I/O (GPIO) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
10.3.2 I/O pin alternate function multiplexer and mapping . . . . . . . . . . . . . . . 403
10.3.3 I/O port control registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
10.3.4 I/O port data registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
10.3.5 I/O data bitwise handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
10.3.6 GPIO locking mechanism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
10.3.7 I/O alternate function input/output . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
10.3.8 External interrupt/wake-up lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 405
10.3.9 Input configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
10.3.10 Output configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
10.3.11 Alternate function configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407
10.3.12 Analog configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
10.3.13 Using the LSE oscillator pins as GPIOs . . . . . . . . . . . . . . . . . . . . . . . 408
10.3.14 Using the GPIO pins in the RTC supply domain . . . . . . . . . . . . . . . . . 408
10.3.15 Using PH3 as GPIO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
10.4 GPIO registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 409
10.4.1 GPIOx mode register (GPIOx_MODER) (x = A to B) . . . . . . . . . . . . . . 409
10.4.2 GPIOx output type register (GPIOx_OTYPER) (x = A to B) . . . . . . . . . 410
10.4.3 GPIOx output speed register (GPIOx_OSPEEDR) (x = A to B) . . . . . . 410
10.4.4 GPIOx pull-up/pull-down register (GPIOx_PUPDR) (x = A to B) . . . . . 411
10.4.5 GPIOx input data register (GPIOx_IDR) (x = A to B) . . . . . . . . . . . . . . 411
10.4.6 GPIOx output data register (GPIOx_ODR) (x = A to B) . . . . . . . . . . . . 412
10.4.7 GPIOx bit set/reset register (GPIOx_BSRR) (x = A to B) . . . . . . . . . . . 412
10.4.8 GPIOx configuration lock register (GPIOx_LCKR) (x = A to B) . . . . . . 413
10.4.9 GPIOx alternate function low register (GPIOx_AFRL) (x = A to B) . . . 414
10.4.10 GPIOx alternate function high register (GPIOx_AFRH) (x = A to B) . . 414
10.4.11 GPIOx bit reset register (GPIOx_BRR) (x = A to B) . . . . . . . . . . . . . . . 415
10.4.12 GPIOC mode register (GPIOC_MODER) . . . . . . . . . . . . . . . . . . . . . . 415
10.4.13 GPIOC output type register (GPIOC_OTYPER) . . . . . . . . . . . . . . . . . 416
10.4.14 GPIOC output speed register (GPIOC_OSPEEDR) . . . . . . . . . . . . . . 416
10.4.15 GPIOC pull-up/pull-down register (GPIOC_PUPDR) . . . . . . . . . . . . . 417
10.4.16 GPIOC input data register (GPIOC_IDR) . . . . . . . . . . . . . . . . . . . . . . 418