The pins of a microcontroller can be controlled by a program to output high or low levels, which can be considered the output voltage of the microcontroller. However, the program cannot control the output current of the microcontroller. The output current of the microcontroller depends largely on the external devices on the pins.
When the microcontroller outputs a low level, external devices are allowed to input current into the microcontroller pins. This current is called "injection current" and the external circuit is called "injection current load" . When the microcontroller outputs a high level, external devices are allowed to pull current out from the microcontroller pins. This current is called "source current" and the external circuit is called "source current load".
What are the typical currents? What is the maximum limit? This is a common question about the output drive capability of a microcontroller.
The load capacity of the early 51 series microcontrollers was very small, and was only described by "how many TTL inputs it could drive". Each pin of the P1, P2 and P3 ports can drive 3 TTL inputs, and only the P0 port has a strong capacity, which can drive 8!
If we analyze the input characteristics of TTL, we can find that the 51 MCU basically has no driving ability. Its pins can't even drive the LEDs at that time to emit light normally. I remember that it was only after the AT89C51 MCU became popular that we found that the ability of the MCU pins was greatly enhanced and could directly drive the LEDs to emit light.
From the PDF manual of the AT89C51 microcontroller, we can see that the upper limit of the "sink current" in steady-state output is:
Maximum IOL per port pin: 10 mA;
Maximum IOL per 8-bit port
port 0: 26mA,Ports 1, 2, 3: 15mA;
Maximum total I for all output pins: 71 mA.
Here it says:
When each single pin outputs a low level, the external circuit is allowed to sink a maximum current of 10 mA into the pin; each 8-bit interface (P1, P2 and P3) allows a maximum total current of 15 mA to be injected into the pin, while P0 is more capable and allows a maximum total current of 26 mA to be injected into the pin; the maximum sum of the currents allowed by all four interfaces is 71 mA.
When these pins "output high level", what about the "current source" capability of the microcontroller? It can be said to be too poor, less than 1 mA.
The conclusion is: when the microcontroller outputs a low level, the driving capability is acceptable, but when it outputs a high level, it has no ability to output current. This conclusion is based on the data given in the manual.
These characteristics of the 51 microcontroller are derived from the internal structure of the pins. I will not draw a diagram of the internal structure of the pins here, as it can be found in many books.
Inside the chip, there is a transistor between the pin and the ground, so the pin has the ability to pull down, and when the output is low, it allows 10mA of current to be injected; and there is an "internal pull-up resistor" of several hundred K between the pin and the positive power supply, so when the pin is at a high level, the pull-up current that can be output is very small. Especially for the P0 port, there is no pull-up resistor inside, so the P0 port has no ability to output high-level current.
Oh, I see. If the external circuit is a "current-pulling load" and requires the microcontroller to function when outputting a high level, then a "pull-up resistor" must be used to assist in generating the current required by the load.
The following discussion will specifically talk about the problems with pull-up resistors.
As mentioned above, D2 emits light due to the current provided by the pull-up resistor R2. The voltage when D2 is turned on is about 2V, so the current is: (5 - 2) / 1K, which is about 3mA.
When the microcontroller outputs a low level (0V) and D2 does not emit light, is the pull-up resistor R2 idle? No! The voltage across it is higher than when the LED emits light, now it is 5V, and the current is 5mA! Have you noticed? When the LED does not emit light, the pull-up resistor gives a larger current! And this current, which is greater than the normal light-emitting current, is all poured into the pins of the microcontroller! If 8 1K pull-up resistors are installed in an 8-bit interface, when the microcontroller outputs a low level, a current of 40mA will be poured into this 8-bit interface! If four 8-bit interfaces are all equipped with 1K pull-up resistors, the maximum possible current is 32 × 5 = 160mA, all flowing into the microcontroller! This value has exceeded the upper limit given in the microcontroller manual. If the microcontroller is unstable at this time, it is natural.
Moreover, these currents appear when the load is in an invalid state. They are completely useless currents and only cause heat, high power consumption, fast battery consumption and other consequences.
Especially now, energy conservation, emission reduction and low carbon are being advocated.
So, can we make the pull-up resistor larger?
The answer is: No, because it is needed to provide current for the current-pulling load. For LEDs, if the resistance is increased, the current will be too small, the light will be dim, and the function of the light-emitting diode will be lost.
For D1, it is a current sinking load. When the microcontroller outputs a low level, there will be current sinking in the R1 and D1 paths. When the microcontroller outputs a high level, there will be no current, and no additional power consumption will be generated.
In summary, current sinking load is reasonable, while "current pulling load" and "pull-up resistor" will generate a lot of invalid current, and this circuit is unreasonable. Some netizens have a special liking for pull-up resistors, and they want to install a pull-up resistor on the pin, whether it is useful or not, and they can even give some reasons: stability and speed.
In fact, "pull-up resistors" and "current pull-up load" circuits will cause adverse consequences to the microcontroller system. I have read many books and reference materials about microcontroller pins and pull-up resistors, but basically they have not discussed the disadvantages of using pull-up resistors in detail.
Here, Zuoerlundao solemnly proposes to everyone: When designing the load circuit of the microcontroller , the circuit form of "current injection load" should be used to avoid unnecessary current consumption. The pull-up resistor is only considered at the P0 port: when the P0 port is used as an input port, it needs to be added; when the P0 port is used to output a high level to drive a MOS type load, it also needs to be added. At other times, the P0 port does not need to add a pull-up resistor. Pull-up resistors should not be added to other interfaces (P1, P2 and P3), especially when the output is valid at a low level, the external device has the function of pull-up.
Previous article:FPGA microcontroller shows you how to implement multi-machine serial communication network
Next article:"Power failure" cannot be ignored. The single-chip microcomputer system provides conditions for circuit protection
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- Have you ever used a conical inductor?
- MSP430 download unknown devices problem solved
- [Project source code] Audio acquisition + FFT spectrum analysis + VGA display spectrum value based on FPGA
- EPLAN
- Download to get gifts | TE outdoor monitoring, an important guarantee and trend choice for creating a safe and stable society!
- How to process the signal of BLDC feedback speed measuring motor
- Seeking agent chip GD32F405
- "Play Board" + STM32F407 core board voice-controlled colored lights
- There may be a cure for the bald self! Tencent AI analyzes the cause of male baldness for the first time
- [TI recommended course] #Boost and buck-boost DCDC converters help wireless charging design#