Here we briefly understand the specific functions of the 40 pins of the 51 single-chip microcomputer. For readers who have not been exposed to complex electronic components, it may feel very difficult, but in fact there is no need to be afraid.
MCU pins
According to the pin identification method of the integrated circuit, with the notch facing up, turn counterclockwise, the pins of the microcontroller are numbered from 1 to 40, as shown in the figure. The name of each pin is also given in the figure. We don't need to deliberately remember the order and name of these pins. Just check them when you need them. If you use them more often, you will naturally remember them later.
According to the brackets in the figure, we call the eight pins P0.0~P0.7 a group of IO ports, called P0, and there are also P1, P2 and P3. IO port (IO = Input / Output), as the name suggests, is the input and output interface, which is the way for the microcontroller to communicate with the outside world. Our main learning content is also centered around the IO port.
In addition, these 32 IO ports have some pin names marked in brackets, which are called second functions; the second function will be enabled under certain circumstances, and when the second function is not enabled, they only serve as IO ports. For example, P3.0 and P3.1 are also called RXD and TXD, which have the function of serial ports, which can be used to download programs to the microcontroller, and can also be used to send and receive data with the computer, that is, serial port communication.
In addition to the 32 IO ports, there are eight pins: pins 29 to 31 are generally not used much, so they will not be introduced for now; pin 40 VCC, pin 20 GND, pin 9 RST, and pins 18 and 19 XTAL1 and XTAL2 will soon be explained in detail in the following microcontroller minimum system.
Minimum system circuit of single chip microcomputer
What is the minimum system of a single-chip microcomputer? The minimum system refers to the simplest circuit that allows the single-chip microcomputer to work normally. For a 51 single-chip microcomputer, the minimum system generally includes: power supply, single-chip microcomputer, clock circuit and reset circuit. Its circuit diagram is as follows:
Now let me introduce to you the functions of these circuits.
Power Circuit
As an electronic device, the 51 microcontroller must be powered by a power supply. It generally uses a 5V power supply. We can get the 5V power supply from the familiar USB interface. In the figure, each VCC symbol is connected to the positive pole of the 5V power supply; and all the GND symbols are connected together and connected to the negative pole of the power supply. The reason why they are not connected together in the figure, but multiple VCC and GND symbols are used, is to make the circuit diagram look clearer and simpler.
VCC = Volt Current Condenser, which indicates the supply voltage.
GND = Ground. The meaning of grounding can be simply understood as connecting to the negative pole of the power supply. We use GND as the reference voltage, and the voltage value of GND is always 0V.
Pay special attention not to connect the microcontroller to too high a voltage or connect the positive and negative poles of the power supply in reverse, which may burn the microcontroller or even cause an explosion. If the microcontroller is plugged into a chip socket, since VCC and GND are in symmetrical positions, plugging it in reverse will cause the power supply to be connected in reverse, so be sure to avoid this.
One more thing to add here is that if you need to know the power supply voltage used by a chip, you can usually check the official chip manual, which will be introduced later.
Clock circuit
The circuit connected between pins XTAL1, XTAL2 and GND is the clock circuit (XTAL = External Crystal Oscillator). The power supply is easy to understand, but what is the clock circuit? What is its use? The clock circuit is like a human heart, beating every moment, and is crucial to the microcontroller. Just as the heart continuously transports blood and oxygen to our body, allowing various organs of the body to work normally, the clock circuit is the driving force for the normal operation of various circuits inside the microcontroller.
The clock circuit is composed of a crystal oscillator and a capacitor. A crystal oscillator is an electronic component made of quartz. When powered on, a specific frequency of oscillation will occur on its surface. Finally, a clock signal with a very stable frequency can be output through the circuit to drive the microcontroller to work. Our human heart beats dozens to hundreds of times per minute, which is too slow for a microcontroller. The crystal oscillator frequency in the figure is 12MHz (1MHz=1,000,000Hz). When working normally, it oscillates 12,000,000 times per second! In fact, the crystal oscillator of the clock circuit does not have to be 12M, it can also be other, but it should be noted that the maximum operating frequency of the STC89C51 microcontroller cannot exceed 80M (this can also be found in the chip manual). In fact, we use more 11.0592M crystal oscillators. Why is it such a strange frequency? I believe readers will understand when we talk about the serial port later.
The clock circuit also uses two capacitors, C2 and C3. If you don't know much about capacitors, you can look for information on common electronic components. I won't introduce them here. These two capacitors are usually ceramic capacitors, and the capacity is generally 30pF.
By the way, if you design the clock circuit yourself, the connection between the crystal oscillator and the microcontroller should not be too long, otherwise the circuit may not work properly (cannot oscillate).
The time it takes for the clock to oscillate once is called a clock cycle; for the 51 microcontroller we are using, the microcontroller performs one operation every 12 clock cycles, which is called a machine cycle.
STC also launched a 1T microcontroller, which performs one operation per clock cycle). If it is a 12M crystal oscillator, the clock cycle is 1/12 us, and the machine cycle is exactly 1 us.
You should still remember the ancient and huge computer ENIAC mentioned earlier. ENIAC could perform 5,000 addition operations per second, which was a very high level at the time. But compared with our 51 single-chip microcomputer, it is really a small witch compared to a big witch. The 51 single-chip microcomputer can perform an addition operation (i.e., assembly instruction ADD) in one machine cycle. With a 12M crystal oscillator, it can perform up to one million addition operations per second, which is 200 times that of ENIAC (not considering the movement of data between registers and memory). Seeing this, are you secretly happy that you can use such a high-tech thing? _
Reset Circuit
The part of the circuit connected to the RST pin in the figure is the reset circuit, which is composed of resistors and capacitors. The function of the reset circuit is to send a signal to the microcontroller when the power is just turned on (for the 51 microcontroller, it is a high level for at least two consecutive machine cycles), telling the microcontroller that it can start working now. Then the microcontroller starts from the initial state and executes a specific program tirelessly until the power is cut off or a special situation occurs that causes the program to terminate. Under normal circumstances, the program execution should not be terminated when the microcontroller is working normally. This issue will be explained later when talking about the characteristics of the microcontroller program.
The principle of the reset circuit is to charge the capacitor through the resistor when the power is turned on, so that the voltage of the capacitor connected to the RST pin changes from 5V to 0V, that is, the high level changes to the low level. The values of the resistor and capacitor can be based on the reference values given in the figure. If you have some knowledge of analog circuits, you can also calculate and determine the values yourself.
Other circuits
In addition, the EA/VPP pin in the figure is used to access the internal or external program memory selection signal and provide programming voltage. It is generally not used much. Just connect it directly to VCC.
When I was actually doing the experiment, I found that the microcontroller could generally work without the reset circuit and the two capacitors on the crystal oscillator. However, for safety reasons, these should still be connected if conditions permit. We need a rigorous scientific attitude.
With the minimum system, the microcontroller can work normally and continuously execute the program we ask it to execute. The spirit of the microcontroller that is not afraid of hardship and fatigue is worth learning.
Previous article:Independent key and matrix keyboard driving principle
Next article:Understanding of serial communication
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- 【Help】Sensor selection for a certain op amp circuit
- DIY thermal imaging is convenient for observing frictional heat generation
- RP2040 components purchased from element14 event
- Flushing steps (smart toilet development record)
- How to speed up MobaXterm pasting
- Award-winning live broadcast | The new Infineon MOSFET based on Source-down technology effectively improves power density, which is visible to the naked eye
- Bike modification series: Modification buttons
- Hot Questions and Answers: What else can you do besides IT?
- Control design of intelligent car based on MSP430 single chip microcomputer
- How to display animation?