Open drain is equivalent to the output port connected to an NPN transistor, and only connected to e, b. c pole is open circuit, you can connect a resistor to 3.3V, or you can connect a resistor to 5V, so that at the output 1 At that time, it can be 5V voltage or 3.3V voltage. But when the resistor is pulled up, this output can not be realized.
Push-pull , there is push and pull, the level of the IO port is determined at any time, no external pull-up or pull-down resistor is required. (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 multiplex open-drain output (8) GPIO_Mode_AF_PP multiplex push-pull output
The push-pull circuit is a diode or MOSFET with the same two parameters. It is in the push-pull mode and is in the circuit. Each of the two is responsible for the positive and negative half-cycle waveform amplification task. When the circuit is working, the two symmetric power switches have only one conduction at a time. Therefore, the conduction loss is small and the efficiency is high. The output can sink current to the load as well as current from the load.
The push-pull output stage both increases the load capacity of the circuit and increases the switching speed.
Open-drain output: The output is equivalent to the collector of the triode. To obtain a high-level state, a pull-up resistor is required. It is suitable for current-type driving, and its ability to sink current is relatively strong (generally within 20ma).
Open-drain circuits have the following characteristics:
1. Reduce the drive inside the IC by using the drive capability of the external circuit. When the internal MOSFET of the IC is turned on, the drive current flows from the external VCC through R pull-up and the MOSFET to GND. Only a very low gate drive current is required inside the IC.
2. Generally speaking, open-drain is used to connect different levels of devices and match the level. Because the open-drain pin is not connected to the external pull-up resistor, it can only output low level. If it needs to have output at the same time. The high level function requires a pull-up resistor. A good advantage is that the transfer level can be changed by changing the voltage of the pull-up power supply. For example, a pull-up resistor can be used to provide TTL/CMOS level output. (The resistance of the pull-up resistor determines the speed of the edge of the logic level transition. The larger the resistance, the lower the speed and the lower the power consumption, so the load resistor should be selected with both power consumption and speed.)
3. OPEN-DRAIN provides a flexible output method, but it also has its weakness, which is the delay of the rising edge. Because the rising edge charges the load through an external pull-up passive resistor, when the resistance is selected, the hour delay is small, but the power consumption is large; otherwise, the delay is large and the power consumption is small. Therefore, if there is a requirement for the delay, it is recommended to use the falling edge output.
4. Pins of multiple open-drain outputs can be connected to one line. Through a pull-up resistor, a "logical" relationship is formed without adding any devices. This is also the principle that I2C, SMBus and other buses determine the bus occupancy status.
Added: What is "line and"? : On a node (line), connect a pull-up resistor to the source CCC or VDD and the collector C or drain D of the n NPN or NMOS transistors. The emitter E or source S of these transistors are connected to ground. On the line, as long as one transistor is saturated, this node (line) is pulled to the ground level. Because of the base injection current (NPN) or the gate plus high level (NMOS) of these transistors, the transistor Will be saturated, so the relationship of these bases or gates to this node (line) is NOR logic. If this node is followed by an inverter, it is OR logic. In fact, it can be simply understood as: at all When the pins are connected together, an external pull-up resistor is connected. If one pin outputs a logic 0, which is equivalent to grounding, the circuit connected in parallel is “equivalent to being short-circuited by one wireâ€, so the logic level of the external circuit is 0, the result of and is only logic 1 when both are high. Since the floating input is generally used for external key input, I understand that the floating state of the IO is indeterminate and is completely determined by the external input . If the pin is left floating, the port is read. The level is uncertain. Pull-up input/pull-down input/analog input: These concepts are well understood and can be easily understood from the literal. Multiplex open-drain output, multiplexed push-pull output: can be understood as the configuration when the GPIO port is used as the second function (ie, not used as a general-purpose IO port)
Finally summarize the use case: select IO mode in STM32
(1) Floating input _IN_FLOATING - floating input, can do KEY recognition, RX1
(2) with pull-up input _IPU - IO internal pull-up resistor input
(3) With pull-down input _IPD - IO internal pull-down resistor input
(4) Analog input _AIN - Apply ADC analog input, or save power at low power
(5) Open-drain output _OUT_OD——IO output 0 is connected to GND, IO output is 1, floating, and an external pull-up resistor is required to achieve output high level. When the output is 1, the state of the IO port is pulled high by the pull-up resistor, but since it is the open-drain output mode, the IO port can be changed to a low level or unchanged by an external circuit. Can read IO input level changes to achieve 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) Push-pull output of the multiplex function _AF_PP - On-chip peripheral function (I2C SCL, SDA)
(8) Open-drain output of the multiplex function _AF_OD - On-chip peripheral function (TX1, MOSI, MISO.SCK.SS)
STM32 setting example:
(1) Analog I2C uses open-drain output _OUT_OD, connected to pull-up resistor, can correctly output 0 and 1; GPIO_SetBits (GPIOB, GPIO_Pin_0) when reading value; pull high, then can read IO value; use GPIO_ReadInputDataBit (GPIOB, GPIO_Pin_0);
(2) If there is no pull-up resistor, IO defaults to high level; you need to read the value of IO, you can use pull-up input _IPU and floating input _IN_FLOATING and open-drain output _OUT_OD.
Product categories of Disc Stylus Pen, We are the specialized manufacturer of Stylus Pen from China. Disc Stylus Pen no need to charge, you can use it directly, it is universal, it is compatible with all brands capacitive touch screens, such as Apple, Huawei, Samsung, Xiaomi, Microsoft, Google Chrome, ect. OEM / ODM are welcome, looking forward to our cooperation.
Disc Stylus Pen,Digital Stylus Pen,Cute Ballpoint Pen,2 In 1 Stylus Pencil
Shenzhen Ruidian Technology CO., Ltd , https://www.szwisonen.com