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. After that, our main learning content is also centered around the IO port. In addition, these 32 IO ports have some pin names marked in brackets, called the second function; 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. They 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
Power supply circuit: As an electronic device, the 51 single-chip microcomputer certainly needs power supply. It generally uses a 5V power supply. We can get 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, indicating the power supply voltage; GND = Ground, which means grounding, can be simply understood as connecting to the negative pole of the power supply, and 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
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 all the time, 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 (fail to 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 every 1 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
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:Microcontroller beginner's guide (5) Knowledge about integrated circuits and packaging
Next article:Microcontroller beginners (7) Preparing the experimental board - Different people have different tastes
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- TI CC2531 USB Evaluation Module Kit
- Lantern with capacitive touch support
- TI's active equalization solution
- After the ZIGBEE3.0 online seminar this morning, have you DIYed a home automation control system?
- Overcome last-minute requirement changes with small, leaded SOT-23 thin multiplexers
- Where can I find older ICs?
- Make ADAS technology more popular in vehicles
- What is a hysteresis comparator?
- VICOR DCM2322 isolated regulated DC-DC converter is now available for free!
- Zigbee learning notes---protocol stack NV operation