In STM32, there are 8 types of GPIO configurations:
(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 multiplexed open-drain output
(8) GPIO_Mode_AF_PP multiplexed push-pull output
The three types of outputs that we are most exposed to are push-pull output, open-drain output, and pull-up input.
After reading various scattered information, here is a brief summary:
Regarding push-pull output and open-drain output, we can finally summarize them with the simplest diagram:
The left side is a push-pull output, and the principle is not explained. The right side can be understood as an open-drain output, which needs to be pulled up. The open-drain output can be used as a current output to improve the load capacity, but an external power supply is required.
Floating input: For floating input, it can be understood that the level state of IO is uncertain and is completely determined by external input. If the pin is floating, the level of the port read is uncertain.
Pull-up input: It is to connect VCC and pull-up resistor externally, and the pull-up resistor also limits the current;
Pull-down input: connect an external pull-down resistor to ground, and the pull-down resistor also limits the current;
As shown below, to detect whether the button is pressed:
KEY0, KEY1 and KEY2 are low level effective, while WK_UP is high level effective, and there are no pull-up and pull-down resistors externally, so it is necessary to set up pull-up and pull-down inside the STM32. It is easy to know that the pin corresponding to WK_UP should be set as pull-down input, and other pins should be set as pull-up input. (Low level effective is set as pull-up input, high level effective is set as pull-down input)
Analog input: It is the traditional input method, which inputs an analog quantity and can usually be used as ADC input.
Multiplexed open-drain output, multiplexed push-pull output: can be understood as the configuration when the GPIO port is used as a second function (that is, not used as a general IO port)
For example: when using stm32 serial communication, USART1_TX uses multiplexed push-pull output and USART1_RX uses floating input
For USART1_TX: Because it is a common IO port when the serial port is not available, it is multiplexed. Because there is no pull-up resistor, it is push-pull. Because TX is the data transmission port, it is output. So it is multiplexed push-pull output.
For USART1_RX: Because it is receiving data, the input is left floating.
Finally, let’s summarize the usage:
Select IO mode in STM32
(1) Floating input_IN_FLOATING - floating input, serial port RX1
(2) Pull-up input_IPU - IO external pull-up resistor input
(3) Pull-down input_IPD - IO external pull-down resistor input
(4) Analog input_AIN - ADC analog input, or power saving under low power consumption
(5) Open drain output_OUT_OD - IO output 0 connected to GND, IO output 1, floating, an external pull-up resistor is required to achieve high output level. 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 also be changed to a low level or unchanged by an external circuit. Can read IO input level changes to realize C51 IO bidirectional function
(6) Push-pull output _OUT_PP - IO output 0- connected to GND, IO output 1 - connected to VCC, read input value is unknown
(7) Multiplexed function push-pull output _AF_PP - on-chip external function (TX1, I2C SCL, SDA)
(8) Multiplexed function open-drain output _AF_OD - on-chip external function (MOSI, MISO.SCK.SS)
Note: Please refer to Baidu Library, Atomic STM32 Development Guide and other materials.
Previous article:About STM32 external interrupt
Next article:STM32 driver Nokia5110
Recommended ReadingLatest update time:2024-11-16 23:46
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Electromagnetic compatibility of independent power systems and their power electronic devices
- Bluetooth RF Conformance Test
- Next-Generation C2000 Microcontrollers and CapTIvate Technology Live Broadcast Registration Open!
- Regarding impedance matching, is the characteristic impedance setting of the board trace the same as the series resistor impedance matching?
- EEWORLD University Hall----Live Replay: TI chip technology helps motor development
- ADC Test Voltage vs. Temperature
- [Information] The latest domestic card swiping chip (ultra-low power consumption 13.56M chip)
- Looking to buy a zynq board from Black Gold Technology
- What parameter changes does the OBD2 plug use to obtain the engine speed signal from the OBD interface?
- Study and share information about wildfire motors