A microcontroller is also known as a microcontroller because it was first used in the field of industrial control. Microcontrollers evolved from specialized processors that had only a CPU on a chip. The earliest design concept was to integrate a large number of peripherals and CPU in a chip, so that the computer system is smaller and easier to integrate into the complexity of the requirements of the strict mention of the control equipment, INTEL's Z80 is the earliest in accordance with the idea of the processor design, from then on, the development of microcontrollers and specialized processors will be separated.
Early microcontrollers were 8-bit or 4-bit. One of the most successful was INTEL's 8031, which received great acclaim for its simplicity, reliability, and good performance. Since then, the MCS51 series of microcontroller systems have been developed on the 8031. The microcontroller system based on this system is still widely used until now. With the improvement of the requirements of the industrial control field, 16-bit microcontroller began to appear, but because of the price-performance ratio is not ideal and has not been widely used. 90's with the development of consumer electronics products, microcontroller technology has been greatly improved. With the INTEL i960 series, especially the later ARM series of widely used, 32-bit microcontroller to rapidly replace the 16-bit microcontroller high-end status, and enter the mainstream market. The performance of the traditional 8-bit microcontroller has also been rapidly improved, and the processing power has been increased hundreds of times compared with that of the 80s. At present, the high-end 32-bit microcontroller main frequency has exceeded 300MHz, performance to catch up with the mid-90's dedicated processor, while the ordinary model factory price fell to 1 U.S. dollars, the highest-end model is only 10 U.S. dollars. Contemporary microcontroller systems are no longer developed and used only in bare-metal environments, and a large number of specialized embedded operating systems are widely used on a full range of microcontrollers. The high-end microcontrollers used as the core processing of PDAs and cell phones can even directly use dedicated Windows and Linux operating systems.
Microcontrollers are best suited for embedded systems than dedicated processors, which is why they are the most widely used. In fact microcontrollers are the most numerous computers in the world. Microcontrollers are integrated into almost every electronic and mechanical product used in modern human life. Cell phones, telephones, calculators, household appliances, electronic toys, palmtop computers, and computer accessories such as mice are equipped with 1-2 microcontrollers. Personal computers also have a number of microcontrollers working in them. Automobiles are generally equipped with more than 40 microcontrollers, and complex industrial control systems may even have hundreds of microcontrollers working at the same time! The number of microcontrollers not only far exceeds the combined number of PCs and other computing, but is even greater than the number of humans.
Introduction of microcontroller
Microcontroller, also known as a single microcontroller, it is not the completion of a logical function of the chip, but a computer system integrated into a chip. To summarize: a chip becomes a computer. Its small size, light weight, inexpensive, for learning, application and development to provide a convenient condition. At the same time, learning to use a microcontroller is the best choice to understand the principles and structure of the computer.
Microcontroller internal and computer functions similar to the module, such as the CPU, memory, parallel bus, and hard disk role of the same memory components, the difference is that the performance of these components are relative to our home computer is much weaker, but the price is also low, generally no more than 10 yuan can be ...... Use it to do some control of electrical appliances of a class is not very complex work enough. We now use the automatic drum washing machine, smoke hood, VCD and other home appliances can be seen inside its figure! ...... It is mainly as the core component of the control part.
It is a kind of online real-time control computer, online is the field control, the need is to have a strong anti-interference ability, lower cost, which is also and offline computer (such as home PC) of the main difference.
The microcontroller is dependent on the program, and can be modified. Through different programs to achieve different functions, especially special unique features, which is other devices need to be very hard to do, and some are very difficult to spend a lot of effort to do. A not very complex function if the United States developed in the 1950s 74 series, or the 1960s CD4000 series of these pure hardware to deal with, the circuit must be a large PCB board! But if you use the series of microcontrollers that were successfully marketed in the 70's in the US, the results will be very different! Only because the microcontroller through your program can achieve high intelligence, high efficiency, and high reliability!
Because microcontrollers are cost-sensitive, the dominant software is still the lowest level of assembly language, which is in addition to the binary machine code above the lowest level of language, since it is so low why use it? Many high-level language has reached the level of visual programming why not use it? The reason is very simple, is that the microcontroller does not have a home computer like the CPU, there is no hard disk like the mass storage device. A small program written in a visual high-level language, even if there is only one button, will reach the size of tens of K. For the hard disk of a home PC, it's nothing! This is nothing for the hard disk of a home PC, but it is unacceptable for a microcontroller. Microcontrollers have to be very efficient in the utilization of hardware resources, so assembly is used a lot, even though it is primitive. In the same way, if you take the operating system and application software from a giant computer and run it on a home PC, the home PC can't handle it.
It can be said that the twentieth century spanned three "electric" eras: the electrical era, the electronic era, and now the computer era. However, this computer, usually refers to a personal computer, or PC for short. It consists of a mainframe computer, a keyboard, a monitor, and so on. There is another type of computer that most people are not so familiar with. This type of computer is a microcontroller (also known as a microcontroller) that gives intelligence to various machines. As the name implies, this computer's smallest system uses only a single integrated circuit for simple operations and control. Because of its small size, usually hidden in the controlled machinery "belly". It is in the whole device, plays a role as the role of the human mind, it went wrong, the whole device is paralyzed. Now, the use of this microcontroller has been a very wide range of areas, such as intelligent instrumentation, real-time industrial control, communications equipment, navigation systems, home appliances and so on. Once a variety of products with a microcontroller, you can play a role in upgrading the effectiveness of the product, often in the product name before the adjective - "intelligent", such as intelligent washing machines. Now some factory technicians or other amateur electronic developers to come up with certain products, either the circuit is too complex, or too simple and easy to imitate the function. The reason for this, may be stuck in the product does not use a microcontroller or other programmable logic devices.
Microcontroller applications
Currently, microcontroller penetrates into all areas of our lives, it is difficult to find any field without a trace of microcontroller. Missile navigation devices, aircraft control of a variety of instruments, computer network communication and data transmission, industrial automation process of real-time control and data processing, the widespread use of a variety of intelligent IC cards, civilian limousine security system, video recorders, cameras, automatic washing machine control, as well as programmable toys, electronic pets and so on, all of these are inseparable from the microcontroller. Not to mention the automatic control field of robotics, intelligent meters, medical equipment. Therefore, the study, development and application of microcontroller will create a number of computer applications and intelligent control of scientists and engineers.
Microcontroller is widely used in the field of instrumentation, household appliances, medical equipment, aerospace, intelligent management of special equipment and process control, etc., which can be roughly divided into the following categories:
1. Widely used in instrumentation, combined with different types of sensors, can be realized such as voltage, power, frequency, humidity, temperature, flow, speed, thickness, angle, length, hardness, elements, pressure and other physical measurements. The use of microcontroller control makes instrumentation digital, intelligent, miniaturized and more powerful than with electronic or digital circuits. For example, precision measurement equipment (power meter, oscilloscope, various analyzers).
2. Application in industrial control
With microcontroller can constitute a variety of control systems, data acquisition systems. For example, intelligent management of factory assembly lines, intelligent control of elevators, various alarm systems, and computer networking to form a secondary control system.
3. In the application of household appliances
It can be said that, nowadays, household appliances are basically used in microcontroller control, from the electric cooker, washing machine, refrigerator, air-conditioning, color TV, other audio-video equipment, and then to the electronic weighing equipment, a variety of ubiquitous.
4. Application in the field of computer networks and communications
The modern microcontroller is generally equipped with communication interfaces, can easily communicate with computers for data communication, for the application of computer networks and communications equipment provides excellent material conditions, now the communication equipment basically realize the intelligent control of the microcontroller from the cell phone, telephone, small program-controlled switches, buildings, automatic communication call systems, trains, wireless communication equipment, and so on. Automatic communication call system, train wireless communication, and then to the daily work everywhere in the cell phone, trunking mobile communication, radio intercom and so on.
5. Application of microcontroller in the field of medical equipment
The use of microcontroller in medical equipment is also quite extensive, such as medical respiratory machine, various analyzers, monitors, ultrasound diagnostic equipment and bed call system and so on.
In addition, the microcontroller in the industrial and commercial, financial, scientific research, education, defense and aerospace fields have a very wide range of uses.
Learning should be in the six important parts
Microcontroller learning should be in the six important parts
First, the bus: we know that a circuit is always connected by the components through the wire from the analog circuits, wires do not become a problem, because the devices are generally serial relationship between the device is not a lot of wires, but the computer circuits are not the same! It is a microprocessor as the core, the devices are connected to the microprocessor, the work between the devices must be coordinated with each other, so the need for wiring is a lot, if still as analog circuits, in the microprocessor and the devices are individually wired, then the number of lines will be amazingly high, so in the microprocessor was introduced in the concept of the bus, each device **** with the enjoyment of the wires, all the devices of the eight Data lines are all connected to the 8 common line, that is, the equivalent of each device is connected in parallel, but only this is not enough, if there are two devices at the same time to send out data, a 0, a 1, then, the receiver receives exactly what it is? This situation is not allowed, so it is necessary to control through the control line, so that the device time-sharing work, at any time there can only be a device to send data (there can be more than one device to receive at the same time). The data lines of the device are also known as the data bus, and all the control lines of the device are known as the control bus. In the microcontroller internal or external memory and other devices have storage units, these storage units to be assigned address, in order to use, assign the address is of course also given in the form of electrical signals, due to more storage units, so, for the address of the distribution of the line is also more, these lines are known as the address bus.
Second, data, address, instructions: the reason why these three together, because the essence of these three are the same - digital, or are a string of '0' and '1 ' sequence of '0's and '1's. In other words, addresses and instructions are also data. Instruction: a number specified by the designer of the microcontroller chip, which has a strict one-to-one correspondence with our commonly used instruction mnemonics and cannot be changed by the developer of the microcontroller. Address: is to find the microcontroller internal and external storage units, input and output ports based on the internal unit of the address value has been specified by the chip designer, can not be changed, the external unit can be decided by the developer of the microcontroller, but there are some of the address unit must be there (see the program execution process). Data: This is the object handled by the microprocessor, in a variety of different application circuits vary, in general, the data being processed may be so many kinds of cases:
1?Address (such as MOV DPTR, #1000H), that is, the address of the 1000H sent to the DPTR.
2?Mode word or control word (such as MOV TMOD, #3), 3, that is, the control word.
3?Constant (e.g. MOV TH0, #10H) 10H is the timing constant.
4?The actual output value (such as P1 port connected to the colored lights, to light all bright, then the implementation of the instruction: MOV P1, #0FFH, to light all dark, then the implementation of the instruction: MOV P1, #00H) here 0FFH and 00H are the actual output value. Another example is the character code used for LEDs, which is also the actual output value.
Understanding the address, the nature of the instruction, it is not difficult to understand why the program will run during the process of flying, the data will be treated as instructions to execute. Such as P3.6, P3.7 are WR, RD signals, when the microprocessor external RAM or have an external I/O port, they are used as the second function, can not be used as a general-purpose I/O port, as long as a microprocessor as soon as the execution of the MOVX instruction, there will be a corresponding signal from the P3.6 or P3.7 to send out, do not need to use the instruction in advance. The fact is that 'can't be used as a general-purpose I/O port' is not 'can't' but 'won't' be used as a general-purpose I/O port (by the user). It is perfectly possible to program a SETB P3.7 instruction into a command and have P3.7 go high when the microcontroller executes it, but the user won't do that because it would normally cause the system to crash.
Fourth, the program execution process: microcontroller in the power reset 8051 program counter (PC) in the value of '0000', so the program is always from the '0000' unit to start executing, that is to say: the system must be '0000' in the ROM. In other words: in the system ROM must exist '0000' this unit, and in the '0000' unit must be stored in an instruction.
V. Stack: The stack is a region that is used to store data, the region itself does not have any special features, is a part of the internal RAM, special is the way it stores and accesses the data, that is, the so-called 'first in, last out, last in, first out,' and the stack has a special data transfer instructions, that is, 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', 'PUSH', and so on. 'PUSH' and 'POP', there is a special unit dedicated to its service, i.e., the stack pointer SP, which is automatically added 1 (on top of the original value) whenever a PUSH instruction is executed, and is automatically added 1 (on top of the original value) whenever a POP instruction is executed, and is automatically added 1 (on top of the original value) whenever a POP instruction is executed. (Since the value of SP can be changed with an instruction, the stack can be set in a specified memory cell as long as the value of SP is changed at the beginning of the program, e.g., at the beginning of the program, the stack is set in the cell starting from memory cell 60H with a MOV SP, #5FH instruction. General program at the beginning there is always such an instruction to set the stack pointer, because when the power on, the initial value of the SP for 07H, so that the stack from the 08H unit backward, and 08H to 1FH this region is the 8031's second, third, fourth working register area, often to be used, which will cause data chaos. Different authors write programs to initialize the stack instructions are not exactly the same, which is a matter of author's habit. When the stack area is set up, it does not mean that the area becomes a kind of specialized memory, it can still be used like ordinary memory areas, but in general the programmer will not use it as ordinary memory.
Six, the development process of the microcontroller: The development process described here is not the general book from the beginning of the task analysis, we assume that the hardware has been designed and produced, the following is the work of writing software. Before writing software, the first to determine some constants, addresses, in fact, these constants, addresses in the design phase has been directly or indirectly determined. For example, when the connection of a device is designed, its address is also determined, when the function of the device is determined down, its control word is also determined. Then use a text editor (such as EDIT, CCED, etc.) to write the software, write a good, use the compiler to compile the source program file, check for errors, until there are no syntax errors, in addition to very simple programs, the general application of the software debugging emulator, until the program runs correctly. After running correctly, the chip can be written (the program is solidified in EPROM). After the source program is compiled, a target file with the extension HEX is generated. Generally, the programmer is able to recognize the file in this format, and as long as the file is tuned in, the chip can be written. Here, in order to make you know the whole process, an example:
ORG 0000H
LJMP START
ORG 040H
START:
MOV SP, #5FH ;set the stack
LOOP:
NOP
LJMP LOOP; loop
NOP
LJMP LOOP ; loop
END ; end
Microcontroller learning
Currently, many people do not recognize assembly language. It can be said that it is important to master the programming of microcontrollers in C language, which can greatly improve the efficiency of development. However, beginners can not understand the assembly language of the microcontroller, but must understand the specific performance and characteristics of the microcontroller, or in the field of microcontroller is more deadly. If you do not take into account the microcontroller hardware resources, programming in KEIL with C haphazardly, the result can only be out of the problem can not be solved! It can be said with certainty that the best C language microcontroller engineers are from the assembly out of the programmer because the C language of the microcontroller although it is a high-level language, but it is different from the desktop personal computer VC + + + and what the hardware resources of the microcontroller is not very powerful, unlike our VC, VB and other high-level language to write a program in the desktop PC after all, desktop computers are very powerful hardware, so it can be not to consider the issue of hardware resources. Consider the problem of hardware resources.
The 8051 microcontroller as an example to explain the pins and related functions of the microcontroller;
"Microcontroller Pin Diagram"
40 pins can be roughly divided into four categories according to the function of the pins: power supply, clock, control, and I/O pins.
⒈ power supply:
(1) VCC - chip power supply, connected to +5V;
(2) VSS - ground terminal;
Note: Using a multimeter to test the current of the microcontroller pins are generally 0v or 5v, which is the standard TTL level, but sometimes in the microcontroller program is working when the test result is not the value but between 0v-5v. In fact, this is the multimeter does not reflect so fast only, in a moment of microcontroller pin current is still maintained at 0v or 5v.
Peake clock: XTAL1, XTAL2 - crystal oscillation circuit inverted input and output.
3 Control Lines: There are 4 control lines***,
(1) ALE/PROG: Address Latch Allowed/In-Chip EPROM Programming Pulse
(1) ALE Function: Used to latch the low 8-bit address sent out of the P0 port
(2) PROG Function: For chips with an EPROM on-chip, this pin inputs a programming pulse during the EPROM programming period. programming pulse.
⑵ PSEN: External ROM read select signal.
(3) RST/VPD: Reset/standby power.
① RST (Reset) function: reset signal input.
② VPD function: connect to backup power in case of Vcc power down.
⑷ EA/Vpp: internal and external ROM selection/on-chip EPROM programming power supply.
① EA function: internal and external ROM select terminal.
② Vpp function: for chips with on-chip EPROM, the programming power supply Vpp is applied during EPROM programming.
Sung I/O lines
The 80C51*** has four 8-bit parallel I/O ports: P0, P1, P2, and P3 ports, ****32 pins.
P3 port also has a second function for special signal input and output and control signals (is a control bus)