What exactly are weak pull-ups and strong pull-ups?

        We often hear weak pull-ups, weak pull-downs, and corresponding strong pull-ups and strong pull-downs. What is the concept of strong and weak? How much resistance is strong and weak? 

        To understand this problem, we must first understand the concepts of pull-up resistors and pull-down resistors. Suppose there is such a circuit as below, the MCU needs to detect the on-off of the switch.

        When the switch is closed, the MCU IO detects 0, but when the switch is turned on, the IO pin is in a floating state, which is easily disturbed and is in an unknown state.

        At this time, you can add a resistor to Vdd on the IO port, so that the level can be guaranteed to be a fixed high level 1 when the switch is turned off. This resistor is called a pull-up resistor.

        The pull-down resistor is similar, and its function is to ensure that the level is a fixed low level 0 when the switch is turned off.

So how big should this resistor be?

        First of all, the resistance value should not be too small, because if it is too small, a large current will be generated when the switch is closed, which will cause large power consumption on the one hand, and is not safe on the other. Just imagine the consequences of a resistance of 0.

        In addition, the resistance should not be too large. If the resistance is too large, the pull-up/pull-down effect will be weakened. The larger the value, the closer it is to an open circuit. When the switch is turned off, the IO is closer to the floating state, and the more susceptible to interference. Imagine the effect of infinite resistance.

        Therefore, this resistance is neither too large nor too small, generally a few K to tens of K, taking into account power consumption and pull-up and pull-down functions.

        The concept of strength and weakness is introduced here. Weakness means high resistance, and strong means small resistance. 

Note that this is only a relative concept.

        Generally, the MCU also has an internal pull-up and pull-down resistor, which can be configured to enable or disable it. Taking the STM32F103 as an example, it can be seen from the figure below that there is an internal up-down on/off switch.

        The manual says that it is a weak pull-up/pull-down, and the typical resistance value is 40kΩ

        As a supplementary note, the pull-up and pull-down resistors described above are for MCU IO input, and may also be used for output. For example, for open-drain output IO, a pull-up resistor must be added, otherwise the output will not be high. The reason is that the open-drain output structure is as follows, and the drain is open

        It has only one NMOS. When the control output is 0, the NMOS is turned on, and the Output Pin outputs 0, but when the control output is 1, the NMOS is turned off, and the output is in a high-impedance state. To be able to output 1, a pull-up resistor must be connected outside.

        The advantage of this structure can be used in occasions where the levels do not match. It can flexibly output high levels such as 1.8V/3.3V/5V, as long as Vdd is connected to different voltages. In addition, it also has the characteristic of "wire and", that is, multiple open-drain pins are connected together, and it can output high level only when each one outputs 1, as long as there is one output 0, all pin voltages are controlled pull down. The common IIC bus uses this structure

        The selection of the resistance value of this pull-up resistor is also particular, and it should neither be too small nor too large. Because if it is too small, the IO port will bear a large input current, and the input current of the IO is limited. If it is too large, it will affect the communication speed of the IIC, because there is a load capacitor on the bus. If the resistance is too large, the charging and discharging time of the capacitor will be long, which will affect the rising edge and falling edge time. For this specific calculation, you can refer to a document from TI: https://www.ti.com/lit/ml/slva689/slva689.pdf?ts=1679814584051

        The documentation describes the calculation method in detail:

        Finally, I would like to ask you a question, why does the IIC bus not use push-pull output? Comments are welcome in the message area.

Guess you like

Origin blog.csdn.net/jk_101/article/details/130690740