Microcontroller beginner's guide (6) The smallest microcontroller system - small but complete

Publisher:太白山人Latest update time:2016-05-23 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Previously, we introduced the pin number identification of integrated circuits. Here we will briefly understand the specific functions of the 40 pins of the 51 microcontroller. 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

 

IMG_0641_1_1

 

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.

 

4eca28e6003e829f6ee6e513218b4b88

 

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:

  

 

Minimal system.png

 

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.

================================================== =====

Reference address:Microcontroller beginner's guide (6) The smallest microcontroller system - small but complete

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

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号