"Open-drain and Push-pull"
The function of Gpio is simply that it can be configured as input or output according to its own needs. (General Purpose Input Output, referred to as a gpio or bus extender, simplifies the expansion of I/O ports with industry-standard i²c, smbus™, or spi™ interfaces.) GPIO products provide additional control and monitoring capabilities when the microcontroller or chipset does not have enough I/O ports or when the system requires remote serial communication or control. However, when configuring the Gpio pins, two modes are often seen: open-drain (open-drain, open-drain) and push-pull (push-pull).
"Push-pull push-pull output"
Principle:
The output device is a pair of complementary mosfets integrated into the output pin, which outputs high when the Q1 is on, Q2 Cutoff, and low when the Q1 is on, Q2 on. Push-pull output, in fact, the internal use of two transistors (transistor), here is called Top-transistor and Bottom-transistor. The corresponding level is output by the transistor corresponding to the switch. Top-transistor Open (bottom-transistor off), output is high, bottom-transistor on (top-transistor off), output low. The push-pull is capable of leakage currents (sink current) and the ability to set current (source currents). It may have, perhaps, no other state: high-impedance (high impedance) state. Additional pull-up resistors are not required unless the push-pull needs to support additional high impedance states.
Features: In the CMOS circuit should be called CMOS output is more appropriate, because in the CMOS push-pull output capacity can not do the double pole so large. The output capability looks at the area of the IC's internal output pole N tube p tube. The Push-pull is now the most used output stage design in CMOS circuits.
Advantages: (1) The current can be sucked, but also through the current, (2) and the open-drain output compared to the high and low level of the IC push-pull, not simple logic operation.
Disadvantage: There can only be one push-pull output device on a bus;
"Open-drain Open Drain Output"
Principle:
The open-drain circuit refers to a circuit with a very high output of the MOSFET leakage. A MOSFET (Q1) with an n-channel between the internal output and the ground, which can be used for level shifting applications. The output voltage is determined by VCC. VCC can be greater than input high voltage VCC (call up-translate) can also be lower than input high level voltage VCC (call down-translate)
Open-drain output, it is less than push-pull a top transistor, only the bottom transistor. (as in push-pull) when the bottom transistor is off, the output is high. There is no way to output a high level, you want to output a high level, must be externally connected with a pull-up resistor (pull-up resistor). The Open-drain is only capable of leakage currents (sink current), and a pull-up resistor is required if you want to set the current.
Advantages:
(1) Very useful for level shifting between various voltage nodes, can be used for up-translate and down-translate conversion of various voltage nodes
(2) can be a plurality of open-drain pin pin, connected to a line, forming a "and logic" relationship, that is, "line and" function, any one lower, open the line logic is 0. This is also the principle of I2c,smbus bus to determine the state of bus occupancy.
(3) The drive capability of external circuit is used to reduce the internal drive of IC. When the IC internal MOSFET is on, the drive current is from the external VCC through R pull-up, MOSFET to GND. Only a small gate drive current is required inside the IC.
(4) can change the voltage of the pull-up power supply, change the transmission level, the logic level of the IC is determined by the power Vcc1, and the output high level is determined by VCC2. This allows us to control the output of high logic with low level logic.
Principle of OD output level
Disadvantage: The open-drain pin does not connect the external pull-up resistor, only the low level is output. When the output level is low, the N-channel transistor is on, so that a continuous current flows between VCC ' and gnd through the pull-up resistor R and transistor Q1. This can affect the power consumption of the entire system. A pull-up resistor with a larger value can reduce the current. However, a large resistance will slow the rise time of the output signal. That is, the resistance of the pull-up resistor R pull-up determines the speed at which the logic level transitions along. The greater the resistance, the lower the power consumption. Vice versa.
The common Gpio mode can be configured as Open-drain or Push-pull, which is typically configured to Open-drain or push-pull by configuring some bits of the corresponding register. When we go through the CPU to set a bit of those gpio configuration registers, the internal implementation of its GPIO hardware IC is to open or close the corresponding top transistor. Correspondingly, if set in order to open-d mode, it is necessary to pull up the resistor to achieve, also can output high level. Therefore, if the internal hardware (internal) itself contains the corresponding pull-up resistor, then the corresponding pull-up resistor will be closed or opened. If there is no corresponding pull-up resistor inside the GPIO hardware IC, then you must provide the corresponding external (external) pull-up resistor in your hardware circuit. The advantage of the push-pull output is that it is fast because the line is driven in two ways. And the line with the pull-up resistor, even if the fastest speed to raise the voltage, the fastest also need a constant rxc time. where r is the resistor, C is the parasitic capacitance (parasitic capacitance), which includes the pin Pin's capacitance and the board's capacitance. However, the relative disadvantage of push-pull is that it often consumes more current, that is, the power consumption is relatively large. The open-drain consumes a relatively small current, limited by the Resistance R, and R cannot be too small, because when the output is low, it needs to sink lower transistor, which means higher power dissipation. One of the benefits of Open-drain is that it allows you to short multiple open-drain circuits, sharing a pull-up resistor, which is known as a wired-or connection, at which point the output can be lowered by pulling the pin pin down on any IO. To output a high level, all outputs are high. This logic, which is the function of "line and", can implement this part of logic without the need for additional gate circuitry.
Turn from:
Crifan (http://bbs.chinaunix.net)
STM32 Push-Pull (push-pull) and open-drain (open-drain)