1. STM32 GPIO structure diagram
GPIO has 8 setting modes: input floating, input pull-up, input pull-down, analog input, open-drain output, push-pull output, push-pull multiplexing function, open-drain multiplexing function, a total of 4 inputs, 2 types Input, 2 multiple functions.
2. Mode description
â‘ Floating input
The Schmitt trigger in the figure is turned on, the status of the IO port can be directly sent to the input register, and the CPU can directly read the input register;
In the above figure, the shaded part is in a non-working state, especially the output circuit in the lower half, which is actually isolated from the port.
The yellow highlighted part shows the data transmission channel. The external level signal enters the STM32 through the IO port numbered 1 on the left, and is reshaped by the Schmitt trigger of number 2 and sent to the input data register of number 3, in the input data register The other end is numbered 4, and the CPU can read the level status of the IO port at any time.
â‘¡Pull up input
The figure above is the configuration of STM32's GPIO with pull-up input mode. Compared with the previous floating input mode, only a pull-up resistor is connected to the upper part of the data channel. According to the STM32 data sheet, the resistance of this pull-up resistor is between 30K~50K.
Similarly, the CPU can read the level status of the IO port at the other end of the input data register at any time.
â‘¢Drop-down input
â‘£Analog input
The Schmitt trigger is turned off, and the signal goes directly to the ADC input;
The configuration of the analog input channel of STM32 is even simpler. The signal enters from the port numbered 1 on the left, and directly enters the ADC module from the end numbered 2 on the right.
Here we see that all the pull-up, pull-down resistors and Schmitt triggers are in the off state, so the input data register will not reflect the level state on the port, that is, under the analog input configuration, the CPU cannot be Valid data is read on the input data register.
⑤Open-drain output mode
After the CPU writes data through the "bit setting/clear register" or "output data register" at the number 1 end, the data bit is transmitted to the number 4 IO port through the number 2 output control circuit.
If the CPU writes logic 1, the N-MOS tube number 3 will be turned off. At this time, the level of the IO port will be determined by the external pull-up resistor. If the CPU writes logic 0, then the number 3 The N-MOS transistor will be in the on state, and the level of the IO port is pulled to the zero potential of VSS by the number 3 N-MOS transistor.
In the upper part of the above figure, the Schmitt trigger is in the on state, which means that the CPU can monitor the status of the IO port at any time at the other end of the "input data register"; through this feature, a virtual IO port is also realized For two-way communication, as long as the CPU outputs logic 1, since the N-MOS tube number 3 is turned off, the level of the IO port will be completely determined by the external circuit. Therefore, the CPU can read the signal of the external circuit in the "input data register". Instead of its own output logic 1.
In the output mode of the GPIO port, there are 3 output speeds available (2MHz, 10MHz and 50MHz). This speed refers to the response speed of the GPIO port drive circuit, not the speed of the output signal. The speed of the output signal is related to the program (chip Internally, multiple output drive circuits with different response speeds are arranged in the output part of the IO port, and users can choose the appropriate drive circuit according to their needs). By choosing the speed to choose different output drive modules, to achieve the best noise control and reduce power consumption. The high-frequency drive circuit has high noise. When high output frequency is not required, please choose a 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 drive module, it is likely to get a distorted output signal.
â‘¥ Open-drain output multiplexing function
⑦Push-pull output mode
⑧Push-pull multiplexed output mode
GPIO push-pull multiplexing output mode, the input of the output control circuit No. 2 is connected to the output terminal of the multiplexing function. At this time, the output data register is disconnected from the output channel and connected to the output signal of the on-chip peripherals. After we configure the GPIO as a multiplexed output function, if the peripheral is not activated, then its output will be uncertain, and the other parts are consistent with the previous mode, including the reading of the "input data register".
3. Application occasions
â‘ Pull-up input and pull-down input can be used to detect external signals; for example, buttons, etc.;
â‘¡Floating input mode. Due to the large input impedance, this mode is generally used for the receiving end of I2C and USART of the standard communication protocol;
â‘¢General push-pull output mode is generally used in the occasions where the output level is 0 and 3.3V. The ordinary open-drain output mode is generally used in situations where the level does not match. If you need to output a high level of 5V, you need an external pull-up resistor. The power supply is 5V. Set the GPIO to open-drain mode. When the output is high-impedance In the state, the 5V level is output from the pull-up resistor and the power supply.
â‘£ For the corresponding multiplexing mode, it is selected according to the multiplexing function of GPIO. If the GPIO pin is used as the output of the serial port, the multiplexing push-pull output mode is used. If it is used in IC, SMBUS and other applications that require multiplexing of lines and functions, use the multiplexed open-drain mode.
⑤When using any open-drain mode, you need to connect a pull-up resistor.
Genki Ippai 1.0 uses high-tech temperature control, food grade pod and high-quality material device. We also upgrade to type-C interface for charging faster. We have developed various flavors for Genki Ippai Pod Systems. Up to 11 flavors provide consumers with more choices. What's more, you can use other brand`s vape pen with our vape pod.
We offer low price, high quality Disposable E-Cigarette Vape Pen,Electronic Cigarettes Empty Vape Pen, E-cigarette Cartridge,Disposable Vape,E-cigarette Accessories,Disposable Vape Pen,Disposable Pod device,Vape Pods to all over the world.
GenkiIppai Pods 1.0,Pod Systems Vape,Vape Pod Device,ZGAR GenkiIppai Pods 1.0 Pod System Vape Kit,Pod System Mini Vape Pod Device
ZGAR INTERNATIONAL(HK)CO., LIMITED , https://www.zgarvapor.com