
“Open-drain output_OUT_OD――IO output 0 is connected to GND, IO output 1, floating, and an external pull-up resistor is required to achieve high output. When the output is 1, the state of the IO port is pulled high by the pull-up resistor, but because it is an open-drain output mode, the IO port can be changed to a low level or unchanged by an external circuit.Can read IO input level changes to realize the IO bidirectional function of C51
“
The difference between the eight STM32 IO port modes
(1) GPIO_Mode_AIN analog input
(2) GPIO_Mode_IN_FLOATING floating input
(3) GPIO_Mode_IPD pull-down input
(4) GPIO_Mode_IPU pull-up input
(5) GPIO_Mode_Out_OD open drain output
(6) GPIO_Mode_Out_PP push-pull output
(7) GPIO_Mode_AF_OD multiplexing open drain output
(8) GPIO_Mode_AF_PP multiplexing push-pull output
The following is a detailed explanation
(1) GPIO_Mode_AIN analog input
That is, the Schmitt trigger is turned off, and the voltage signal is transmitted to the on-chip peripheral module (not connected to the pull-down resistor)
(2) GPIO_Mode_IN_FLOATING floating input
In the floating input state, the level state of IO is uncertain, which is completely determined by the external input. If the pin is floating, it is uncertain to read the level of the port
(3) GPIO_Mode_IPD pull-down input GPIO_Mode_IPU pull-up input
Generally speaking, the pull-up resistance is 1K-10K, the smaller the resistance, the stronger the driving ability
The function of the resistance: prevent the input terminal from floating, reduce the interference of external current on the chip, limit current; increase the driving ability when high-level output.
Pull-up input: in the default state (the GPIO pin has no input) is high
Pull-down input: in the default state (the GPIO pin has no input) is low level
(4) GPIO_Mode_Out_OD open drain output
Open-drain output: The output terminal is equivalent to the collector of a triode. To get a high level state, a pull-up resistor is needed. Suitable for current type drive,
Its ability to absorb current is relatively strong (generally within 20ma).
(5) GPIO_Mode_Out_PP push-pull output
Push-pull output: can output high and low levels, connect to digital devices;
(6) GPIO_Mode_AF_OD multiplexed open-drain output GPIO_Mode_AF_PP multiplexed push-pull output
Multiplexed open-drain output, multiplexed push-pull output: It can be understood as the configuration when the GPIO port is used as the second function (that is, it is not used as a general-purpose IO port)
Choose IO mode in STM32
(1) Floating input _IN_FLOATING-floating input, can be used for KEY identification, RX1
(2) With pull-up input _IPU-IO internal pull-up resistor input
(3) With pull-down input _IPD-IO internal pull-down resistance input
(4)Analog input_AIN――Apply ADC analog input, or save power under low power consumption
(5) Open-drain output_OUT_OD-IO output 0 is connected to GND, IO output 1 is left floating, and an external pull-up resistor is required to achieve high output. When the output is 1, the state of the IO port is pulled high by the pull-up resistor, but because it is an open-drain output mode, the IO port can be changed to a low level or unchanged by an external circuit.Can read IO input level changes to realize the IO bidirectional function of C51
(6) Push-pull output _OUT_PP-IO output 0-connect to GND, IO output 1-connect to VCC, the read input value is unknown
(7) Push-pull output of multiplex function _AF_PP-on-chip peripheral function (SCL, SDA of I2C)
(8) Open-drain output of multiplexed function _AF_OD-on-chip peripheral functions (TX1, MOSI, MISO.SCK.SS)
There are usually 5 ways to use a certain pin function, and their configuration is as follows:
1) As a normal GPIO input: configure this pin as a floating input, a weak pull-up input or a weak pull-down input as required, and do not enable all the multiplexed function modules corresponding to this pin.
2) As a normal GPIO output: configure this pin as push-pull output or open-drain output as required, and do not enable all the multiplexed function modules corresponding to this pin.
3) As a normal analog input: configure this pin as analog input mode, and do not enable all the multiplexed function modules corresponding to this pin.
4) As the input of the built-in peripherals: configure the pin as a floating input, a weak pull-up input or a weak pull-down input as required, and enable a certain multiplexed function module corresponding to the pin at the same time.
5) As the output of built-in peripherals: configure this pin as a multiplexed push-pull output or multiplexed open-drain output as required, and enable all the multiplexed function modules corresponding to this pin at the same time.
The Links: SKKT500-08E FZ1600R17HP4-B2 INFIGBT
Link to this article:A summary of the eight IO port modes of STM32 microcontrollers