Current location - Quotes Website - Collection of slogans - What does gpio alternate function mode mean?
What does gpio alternate function mode mean?
This is the port multiplexing function of STM32 single chip microcomputer. Can be combined with the microcontroller reference manual and official routines. I use STM32F0 series single chip microcomputer, other series are slightly different, but the principle is the same. First of all, take a look at alternate? How is the function mode defined in the program (stm32f0xx_gpio.h, line 62):

Typedef enumeration

{

GPIO_Mode_IN? = 0x00,/*! & ltGPIO input mode? */

GPIO_Mode_OUT? = 0x0 1,/*! & ltGPIO output mode */

GPIO_Mode_AF? = 0x02,/*! & ltGPIO standby function mode */

GPIO_Mode_AN? = 0x03? /*! < gpio analog input/output mode? */

} GPIOMode _ TypeDef

This structure defines the mode of the port. They are: input, output, multiplexing and analog input. The default is ordinary IO port, that is, input or output. At this time, the port of single chip microcomputer can only input or output high and low levels, and cannot be used for other peripherals (such as PWM, UART, SPI, etc. ).

So if this port is used as the output port of the peripheral, how to set it? Yes, it is GPIO_Mode_AF, which means port reuse.

To sum up, if the port is only used as an input/output port signal, the setting mode is normal IO; If peripherals are used, the microcontroller must be set to multiplex mode, i.e. GPIO_Mode_AF.

By the way, STM32F 1 serial ports are a little more complicated. There are seven modes, which are divided into primary multiplexing and secondary multiplexing, but the principle is the same.