lundi 16 février 2015

GPIO on the STM32


General Purpose Input Output (GPIO)
The STM32 is well served with general purpose
IO pins, having typically 80 bidirectional IO pins.
The IO pins are arranged as five ports each
having 16 IO lines.

Configuration Registers
The STM32 has four configuration registers for each of the ports.

Port mode register – GPIOx_MODER
Output type register – GPIOx_OTYPER
Speed register – GPIOx_OSPEEDR
Pull-up/Pull-down register – GPIOx_PUPDR

Each of these registers is 32-bits wide although not all of the bits are used in all of the registers.

  • GPIO_Mode: Mode of pins operation
    • GPIO_Mode_IN: Set pin to input
    • GPIO_Mode_OUT: Set pin to be an output
    • GPIO_Mode_AF: Set pin to alternating function (to use with peripheral ex. SPI, USART, etc)
    • GPIO_Mode_AN: Set pin to be an analog (ADC or DAC)

  • GPIO_OType: Mode for pin’s output type
    • GPIO_OType_PP: Output type is push-pull
    • GPIO_OType_OD: Output type is open drain

  • GPIO_PuPd: Select pull resistors or disable it
    • GPIO_PuPd_UP: Enable pull up resistor
    • GPIO_PuPd_DOWN: Enable pull down resistor
    • GPIO_PuPd_NOPULL: Disable pull resistor

  • GPIO_Speed: Select GPIO speed
    • GPIO_Speed_100MHz
    • GPIO_Speed_50MHz
    • GPIO_Speed_25MHz
    • GPIO_Speed_2MHz




 EXEMPLE :