In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to understand stm32 GPIO. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. Brief introduction of GPIO
1. GPIO input / output mode
The input and output pins of STM32 can be configured in the following 8 ways:
Input
① floating input _ IN_FLOATING-floating input, which can be used for KEY identification
② with pull-up input _ IPU-- IO internal pull-up resistor input
③ with drop-down input _ IPD-- IO internal drop-down resistance input
④ analog input _ AIN-apply ADC to simulate input, or save power at low power consumption
Output
⑤ open-drain output _ OUT_OD-- IO output 0 and GND,IO output 1, suspended, external pull-up resistor is required to achieve high output level.
⑥ push-pull output _ OUT_PP-- IO output 0-then GND, IO output 1-VCC, the read input value is unknown.
Push-pull output of ⑦ Multiplexing function _ AF_PP-- Chip Peripheral function (I2C SCL,SDA)
Open-leak output of ⑧ Multiplexing function _ AF_OD-- Chip Peripheral function (TX1,MOSI,MISO,SCK,SS)
2. Detailed explanation of input and output mode
1 push-pull output:
It can output high and low levels and connect digital devices; push-pull structure generally means that two transistors are controlled by two complementary signals, always when one transistor is turned on and the other is cut off. The high and low level is set by the power supply of the IC.
The push-pull circuit is two transistors or MOSFET with the same parameters, which exist in the circuit in push-pull mode, each responsible for the waveform amplification task of positive and negative half-cycle. When the circuit works, only one of the two symmetrical power switches is turned on at a time, so the turn-on loss is low and the efficiency is high. The output can not only pour current into the load, but also extract current from the load. The push-pull output stage not only improves the load capacity of the circuit, but also improves the switching speed.
2 Open-leak output:
The output end is equivalent to the collector of the transistor. To get a high-level state, you need to pull up the resistor. Suitable for current mode drive, its ability to absorb current is relatively strong (generally within 20mA)
The open-leak circuit has the following characteristics:
1. Make use of the driving ability of the external circuit to reduce the internal driver of IC. When the internal MOSFET of the IC is turned on, the driving current flows from the external VCC through R pull-up, MOSFET to GND. Only a small gate driving current is needed inside the IC.
2. Generally speaking, open leakage is used to connect devices with different levels and match levels, because open leakage pins can only output low levels when they are not connected to external pull-up resistors. If you need to have the function of outputting high levels at the same time, you need to connect the pull resistors. A good advantage is that the transmission level can be changed by changing the voltage of the pull-up power supply.
3. OPEN-DRAIN provides a flexible output mode, but it also has its weakness, that is, it brings the delay of rising edge. Because the rising edge charges the load by pulling up the passive resistor externally, the delay is small when the resistance is selected, but the power consumption is high; on the contrary, the delay is large and the power consumption is low. Therefore, if there is a requirement for delay, it is recommended to use the falling edge output.
4. Multiple Pin with open and leaky output can be connected to one line. Through a pull-up resistor, a "and logic" relationship is formed without adding any devices. This is also the principle of judging the bus occupation state by buses such as I2C MagneSMBus.
II. GPIO port configuration
1. Configure as input or output according to specific application
① is entered as a normal GPIO:
Configure the pin as floating input, weak pull-up input or weak drop-down input as needed, and do not enable all multiplexing function modules corresponding to the pin.
② output as normal GPIO:
Configure the pin as push-pull output or open-leak output as needed, and do not enable all the multiplexing function modules corresponding to the pin.
③ as normal simulation input:
Configure the pin to be in analog input mode without enabling all the multiplexing functional modules corresponding to the pin.
④ as input to the built-in peripherals:
The pin is configured as floating input, weak pull-up input or weak drop-down input as needed, and a multiplexing function module corresponding to the pin is enabled at the same time.
⑤ as the output of the built-in peripheral:
According to the need, the pin is configured for multiplexing push-pull output or multiplexing open-leak output, and all the multiplexing function modules corresponding to the pin are enabled.
2. Configure speed in output mode
In the output mode of I / O port, there are three kinds of output speeds (2MHz, 10MHz and 50MHz). This speed refers to the response speed of the driver circuit rather than the speed of the output signal, and the speed of the output signal is related to the program (several output driver circuits with different response speeds are arranged in the output part of the I / O port, and users can choose the appropriate driver circuit according to their own needs). Different output driver modules are selected by selecting speed to achieve the best noise control and reduce power consumption. The high frequency drive circuit also has high noise. When the high output frequency is not needed, please choose the low frequency drive circuit, which is very helpful to improve the EMI performance of the system. Of course, if you want to output a higher frequency signal, but choose a lower frequency driver module, you are likely to get a distorted output signal. The key is that the pin speed of the GPIO matches the application.
2.1 for serial port, if the maximum baud rate is only 115.2k, then the pin speed of 2m GPIO is enough.
It not only saves electricity but also reduces noise.
2.2 for I2C interface, if you use 400k baud rate, if you want to leave a larger margin, then use 2m
The pin speed of the GPIO may not be enough, so you can choose a 10m GPIO pin speed.
2.3
For SPI interface, if you use 18m or 9m baud rate, the pin speed of 10m GPIO is obviously not enough, you need to choose 50m GPIO pin speed.
On how to understand stm32 GPIO to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
Public static synchronized List getVerifyListInfo (byte [] b) {List signatureVerificat
© 2024 shulou.com SLNews company. All rights reserved.