In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
In this issue, the editor will bring you about the principle, characteristics, selection and configuration of STM32 GPIO. The article is rich in content and analyzes and describes it from a professional point of view. I hope you can get something after reading this article.
one
Basic structure
STM32 GPIO is the abbreviation of universal input / output port, which can realize input, output, driver, communication and other functions. There are 8 modes (4 input modes and 4 output modes) in STM32 port. Each port bit supports three maximum flip speeds (2MHz, 10MHz, 50MHz), which can be programmed freely, but the port register must be accessed according to 32-bit word, half-word (16-bit) or byte (8-bit). The specific mode is as follows:
Floating input
Pull-up input
Drop-down input
Analog input
Open-leak output
Push-pull output
Multiplexing function push-pull output
Multiplexing function open-leak output
Taking STM32L011 as an example (other STM32 processors are more or less the same), the basic structure of GPIO is as follows:
Key device analysis: 1, protection diode: prevent the input voltage of the outside of the VDDIOx O pin from being too high or too low, when the pin voltage is higher than the VSS, the upper diode turns on; when the pin voltage is lower than the VSS, the lower diode turns on to prevent the abnormal voltage from being introduced into the chip and cause the chip to burn out. 2. Switch: the switch is a TTL Schottky trigger, which converts the analog signal into digital signals of 0 and 1, but when GPIO is used as the ADC acquisition voltage channel, the signal is no longer converted by the TTL level through the trigger. 3. P-MOS, N-MOS: the unit circuit makes GPIO have the functions of "push-pull output" and "open-leak output". two
Four input modes
STM32 has four input modes: floating input, pull-up input, drop-down input and analog input. In the floating input mode, the level signal of the Ihammer O port is determined by the external input, the level state is uncertain, and finally goes directly into the input data register. Floating input is usually used to configure the RX pin of USART, as shown in the following figure:
In the pull-up input mode, the Iamp O port is suspended (in the case of no signal input), the level state is kept at high level, when the input level is low, the level state is low, and finally goes directly into the input data register, as shown in the following figure:
In the drop-down input mode, the Iamp O port is suspended (in the case of no signal input), the level state is kept at low level, when the input level is high, the level state is high, and finally goes directly into the input data register, as shown in the following figure:
In the analog input mode, the analog signal (voltage signal, not the level signal) of the Ihammer O port is directly analog input to the on-chip peripheral module, such as the ADC module. Analog input is usually used in scenarios such as ADC analog input or power saving at low power consumption, as shown in the following figure:
three
Four output modes
STM32 has four output modes: open-drain output, push-pull output, multiplexing function open-leak output and multiplexing function push-pull output (the pull-up and pull-down resistors of this STM32L011 are common areas, so the output mode has pull-up or pull-down functions). Open-drain output mode, through the configuration of the set / reset register or the value of the output data register, through the N-MOS tube, and finally output to the Imax O port. Open-drain output can only output strong low level, high level must be pulled up by external resistance, the output end is equivalent to the collector of Triode, suitable for current mode drive, its ability to absorb current is relatively strong (generally within 20ma), as shown in the following figure: you need to pay attention to the characteristics of N-MOS transistors. When the output level is set to high level, N-MOS transistors are turned off. At this point, the level of the Imap O port will not be determined by the output level, but by the pull-up or pull-down inside or outside the Imap O port. When the output level is set to low level, and the N-MOS transistor is turned on, the level of the Ihammer O port is low. Push-pull output mode, through the configuration of the set / reset register or the value of the output data register, P-MOS tube and N-MOS tube, the final output to the Imax O port. Push-pull output can output strong high and low levels and connect digital devices, as shown in the following figure: you need to pay attention to the characteristics of P-MOS transistors and N-MOS transistors. When the output level is set to high, P-MOS transistors are on and N-MOS transistors are closed. At this time, the level of the P-MOS O port is determined by the P-MOS transistor. When the output level is set to low level, the P-MOS transistor is turned off and the N-MOS transistor is turned on, the level of the N-MOS O port is determined by the N-MOS transistor: low level.
The principles of open-drain output mode and push-pull output mode of multiplexing function are basically the same as those of open-drain output mode and push-pull output mode, except that the high and low output level is not determined by the value of MCU configuration setting / reset register or output data register, but by using the multiplexing function of on-chip peripheral module (communication interface (SPI,UART,I 2C can). LCD, timer, debug interface, etc.). The multiplexing function open-leak output is usually used for the configuration of TX1, MOSI, MISO and other pins, and the multiplexing function push-pull output is usually used for I2C SCL and SDA. Taking the reuse function push-pull output mode as an example, the implementation principle is shown in the following figure:
4GPIO selection and configuration how to choose the GPIO mode and configuration suitable for its application development? Please refer to the following figure.
The above is the principle, characteristics, selection and configuration of STM32 GPIO shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
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
© 2024 shulou.com SLNews company. All rights reserved.