Introduction
On February 15, 1946, the first electronic digital computer ENIAC
was born, marking the arrival of the computer age.
ENIAC
was a vacuum tube computer, with a clock frequency of only 100 kHz, but it could complete 5000 addition operations within 1s
. Compared to modern computers, ENIAC
has many shortcomings, but its birth opened a new era of computer science and technology, greatly impacting human production and lifestyle.
During the development of ENIAC
, Hungarian mathematician John von Neumann served as an advisor to the development team and made significant contributions to the design of the scheme.
In June 1946, von Neumann proposed the concepts of “program storage” and “binary operations,” further constructing the classic structure of computers composed of an arithmetic unit, controller, memory, input devices, and output devices.
The development of electronic computer technology has successively gone through five eras: vacuum tube computers, transistor computers, integrated circuit computers, large-scale integrated circuit computers, and ultra-large-scale integrated circuit computers. However, the structure of computers has not broken through the classic structure framework proposed by von Neumann.
1. Composition and Application Forms of Microcomputers
1. Composition of Microcomputers
In January 1971, Ted Hoff of Intel, while collaborating with a Japanese commercial communication company to develop a desktop calculator, compressed the original design of more than a dozen chips into three integrated circuit chips.
Two of these chips are used for program and data storage, while the other chip integrates the arithmetic unit and controller along with some registers, known as the microprocessor (i.e. Intel 4004). The microprocessor, memory, and I/O interface circuits together form a microcomputer. Each part is connected through address bus (AB), data bus (DB), and control bus (CB).
2. Application Forms of Microcomputers
From the perspective of application forms, microcomputers can be divided into three types: multi-board machines (system machines), single-board machines, and microcontrollers.
1. Multi-board machines (system machines)
Multi-board machines assemble the microprocessor, memory, I/O interface circuits, and bus interfaces on a mainboard (i.e. microcomputer motherboard), and connect keyboards, monitors, printers, soft/hard disk drives, and optical drives through system buses and other peripheral adapter cards. Various adapter cards are plugged into expansion slots on the mainboard and are housed in the same chassis with power, soft/hard disk drives, and optical drives. When paired with system software, it forms a complete microcomputer system, referred to as a system machine.
The personal computer (PC
) that people widely use today is a typical multi-board microcomputer. Due to its good human-computer interface, powerful functions, and rich software resources, it is usually used for office or home task processing and scientific computing, making it a universal computer that has become the most commonly used tool in various fields of society.
Additionally, by reinforcing the chassis of the system machine and designing the base plate as a small base plate structure without a CPU
, inserting the motherboard and various measurement and control boards into the expansion slots of the base plate, a industrial PC
can be constructed. Due to its user-friendly interface and abundant software resources, industrial PC
s are commonly used as the mainframes of industrial measurement and control systems.
2. Single-board machines
A single-board microcomputer consists of a CPU
chip, memory chips, I/O
interface chips, and simple I/O
devices (keypads, LED displays) assembled on a printed circuit board, paired with a monitoring program (firmly stored in ROM), forming a single-board microcomputer, referred to as a single-board machine. A typical product is TP801
.
Single-board machines have simple I/O devices, limited software resources, and are inconvenient to use. They were primarily used for teaching the principles of microcomputers and simple measurement and control systems, but are now rarely used.
3. Microcontrollers
A microcontroller integrates a microprocessor, memory, and I/O interface circuits on a single integrated circuit chip, forming a single-chip microcomputer, i.e., a microcontroller.
The original design purpose of computers was to improve the speed of data calculations and handle massive amounts of data. Computers that accomplish this task are called general-purpose computers.
As computer technology has developed, people have discovered that computers also possess extraordinary capabilities in logical processing and industrial control. In the field of control, people are more concerned about the low cost, small size, reliability, and flexibility of the computer’s operation.
Especially in applications such as smart instruments, smart sensors, smart home appliances, smart office equipment, automobiles, and military electronics, there is a demand to embed computers into these devices. Computers embedded into control systems (or devices) to achieve embedded applications are called embedded computers, also known as dedicated computers.
Embedded application computers can be categorized into embedded microprocessors (e.g., 386EX), embedded DSP processors (e.g., TMS320 series), embedded microcontrollers (i.e., microcontrollers like the 80C51 series), and embedded systems on chip (SoC).
Microcontrollers are small in size, low in price, and highly reliable, making them uniquely advantageous for meeting embedded application needs.
Currently, microcontroller application technology has become the most commonly used technical means in electronic application system design, and learning and mastering microcontroller application technology holds significant practical importance.
In summary, the development of microcomputer technology is trending in two directions: one represented by system machines as general-purpose computers, focused on improving computing speed while considering control functions in achieving massive high-speed data processing; the other represented by microcontrollers as embedded dedicated computers, focusing on in-chip integration of computer control functions while meeting measurement and control needs of embedded objects.
2. Development History and Current Status of Microcontrollers
2.1 Development History of Microcontrollers
The development of microcontroller technology has been rapid, with a plethora of product types. The entire development process of microcontroller technology can be divided into the following three main stages:
1. Formation Stage of Single-Chip Microcomputers
In 1976, Intel launched the MCS-48 series microcontroller. The early products of this series integrated within the chip: an 8-bit CPU, 1K byte program memory (ROM), 64 bytes of data memory (RAM), 27 I/O lines, and one 8-bit timer/counter.
The main characteristic of this stage is the integration of CPU, memory, I/O interfaces, timer/counter, interrupt system, clock, and other components within a single chip, although the memory capacity is small, addressing range is limited (not exceeding 4K), there are no serial interfaces, and the instruction system is not strong.
2. Performance Improvement Stage
In 1980, Intel introduced the MCS-51 series microcontroller. This series integrated within the chip: an 8-bit CPU, 4K byte program memory (ROM), 128 bytes of data memory (RAM), 4 8-bit parallel interfaces, 1 full-duplex serial interface, and 2 16-bit timer/counters. The addressing range is 64K, and it includes a Boolean processor with strong control functions for bit processing. The main characteristics of this stage are a well-structured system and significantly improved performance, further highlighting the control-oriented features. Now, the MCS-51 has become a recognized classic microcontroller model.
3. Microcontroller Stage
In 1982, Intel launched the MCS-96 series microcontroller. This series integrated within the chip: a 16-bit CPU, 8K byte program memory (ROM), 232 bytes of data memory (RAM), 5 8-bit parallel interfaces, 1 full-duplex serial interface, and 2 16-bit timer/counters. The maximum addressing range is 64K. The chip also has 8 channels of 10-bit ADC, 1 PWM (D/A) output, and high-speed I/O components.
In recent years, many semiconductor manufacturers have integrated interface technology, reliability technology, advanced memory technology, and process technology into the microcontroller based on the 8051 core of the MCS-51 series, producing various powerful and flexible new generation 80C51 microcontrollers. The main feature of this stage is the enhancement of peripheral circuits aimed at measurement and control systems, allowing microcontrollers to be flexibly applied to complex automatic measurement and control systems and equipment. Therefore, the term “microcontroller” better reflects the essence of microcontrollers.
2.2 Current Status of Microcontroller Products
With the continuous development of microelectronic design technology and computer technology, microcontroller products and technologies are constantly evolving. The current status of microcontroller products can be summarized in the following two aspects.
1. The 80C51 series microcontroller products are abundant, and a mainstream position has been established. The improvement in computing speed of general-purpose microcomputers is mainly reflected in the increase of CPU bit count (16-bit, 32-bit, and even 64-bit), while microcontrollers focus more on product reliability, economy, and embedded nature. Therefore, the demand for increased CPU bit count in microcontrollers is not very pressing. Years of practical applications have proven that the system structure of the 80C51 is reasonable and the technology is mature. Thus, many microcontroller chip manufacturers are committed to enhancing the overall functionality of 80C51 microcontroller products, thereby establishing the mainstream product status of the 80C51 series. Recent products compatible with the 80C51 include:
-
The AT89 series microcontroller launched by ATMEL, incorporating Flash memory technology;
-
The 80C51 and 80C552 series high-performance microcontrollers launched by Philips;
-
The W78C51 and W77C51 series high-speed low-cost microcontrollers launched by Winbond;
-
The GMS90/97 series low-voltage high-speed microcontrollers launched by LG;
-
The DS89C420 high-speed (50MIPS) microcontroller launched by Maxim;
-
The C8051F series high-speed SOC microcontrollers launched by Cygnal, etc.
It is evident that the 80C51 has become the de facto mainstream microcontroller series, so this book focuses on the 80C51 to discuss the principles and interface methods of microcontrollers.
2. New products of non-80C51 structure microcontrollers are constantly being launched, providing users with a wider selection. While the 80C51 and its compatible products are popular, some microcontroller chip manufacturers have also launched non-80C51 structure products that have a significant impact, including:
-
Intel’s MCS-96 series 16-bit microcontroller; -
Microchip’s PIC series RISC structure microcontroller; -
TI’s MSP430F series 16-bit low-voltage, low-power microcontroller; -
ATMEL’s AVR series RISC structure microcontroller, etc.
3. Characteristics and Application Fields of Microcontrollers
3.1 Characteristics of Microcontrollers
1. High Control Performance and Reliability
Microcontrollers are designed to meet industrial control needs, so their real-time control functions are particularly strong. Their CPU can directly operate on I/O interfaces, and their bit manipulation capabilities are unmatched by other computers. Moreover, since the CPU, memory, and I/O interfaces are integrated within the same chip, the connections between components are compact, resulting in minimal interference during data transmission and less vulnerability to environmental conditions, thus ensuring very high reliability of microcontrollers. Recently launched microcontroller products have integrated high-speed I/O interfaces, ADC, PWM, WDT, and other components, with further enhancements in low voltage, low power consumption, serial extension buses, control network buses, and development methods (such as in-system programming ISP).
2. Small Size, Low Cost, and Easy Productization
Each microcontroller chip is a complete microcomputer. For large-scale dedicated applications, it is possible to match and select from various microcontroller types, and custom chip designs can be developed to ensure a good correspondence between chip functions and applications. In terms of pin packaging, some microcontroller pins have been reduced to 8 or fewer, thus minimizing the size of application system printed circuit boards, reducing connectors, and simplifying installation. Among modern electronic devices, microcontrollers exhibit a good performance-to-price ratio, which is a key reason for their widespread application.
3.2 Application Fields of Microcontrollers
Due to their excellent control performance and flexible embedded qualities, microcontrollers have found extensive applications in various fields in recent years. They can be broadly categorized into the following areas:
1. Smart Instruments
Microcontrollers are used in various instruments and meters, enhancing their functionality and accuracy, leading to intelligent instruments while simplifying their hardware structure, thus facilitating the upgrade and replacement of instrument products. Examples include various intelligent electrical measuring instruments and smart sensors.
2. Mechatronic Products
Mechatronic products integrate mechanical technology, microelectronics technology, automation technology, and computer technology, featuring intelligent characteristics. Microcontrollers can play a significant role in the development of mechatronic products. Typical products include robots, CNC machine tools, automatic packaging machines, currency counting machines, medical equipment, printers, fax machines, and copiers.
3. Real-Time Industrial Control
Microcontrollers can also be used for the collection and control of various physical quantities. The collection and control of physical parameters such as current, voltage, temperature, liquid level, and flow can be conveniently achieved using microcontrollers. In such systems, utilizing microcontrollers as system controllers allows for the adoption of different intelligent algorithms based on the characteristics of the controlled objects to achieve desired control metrics, thereby improving production efficiency and product quality. Typical applications include motor speed control, temperature control, and automatic production lines.
4. Front-End Modules of Distributed Systems
In complex industrial systems, distributed measurement and control systems are often used to complete the collection of numerous distributed parameters. In these systems, microcontrollers serve as front-end collection modules for the distributed system, offering advantages such as reliable operation, convenient and flexible data collection, and low cost.
5. Home Appliances
Home appliances are another important application field for microcontrollers, with a very broad prospect. Examples include air conditioners, refrigerators, washing machines, rice cookers, high-end bathing equipment, and high-end toys. Additionally, in the transportation field, microcontrollers are widely used in automobiles, trains, airplanes, and spacecraft. Examples include automotive automatic driving systems, aerospace measurement and control systems, and black boxes.
4. Overview of Microcontroller Application System Development
4.1 Development of Microcontroller Application Systems
When designing microcontroller application systems, after completing the hardware system design, corresponding application software must be equipped. Accurate hardware design and good software functionality design are the design goals of a practical microcontroller application system. The process of achieving this goal is called the development of microcontroller application systems. A microcontroller, as an integrated circuit chip that contains the basic components of a microcomputer, does not have development functions compared to general-purpose microcomputers, and must rely on a development machine (a special computer system) to perform the following tasks: 1. Troubleshoot hardware faults and software errors in the application system; 2. The debugged program must be stored in the internal or external program memory chip of the microcontroller.
1. Representation of Instructions
An instruction is a command that prompts the microcontroller to perform a certain operation. Within the microcontroller, instructions are stored in the program memory in binary code in a specific order. Binary code is the machine code (or target code) that the computer can execute directly. For convenience in writing, inputting, and displaying, people usually write machine code in hexadecimal form. For example, the binary code 0000 0100B can be represented as 04H. The meaning of the instruction corresponding to 04H is to add 1 to the content of accumulator A. If written as INC A, it is much clearer, which is called the symbolic instruction.
2. Assembly or Compilation
Symbolic instructions must be converted into machine code that the computer can execute and stored in the program memory of the computer; this conversion is called assembly. There are three common methods of assembly:
-
The first is manual assembly, where designers refer to the microcontroller instruction coding table to translate each symbolic instruction into hexadecimal numbers representing machine code instructions, which are then input into the development machine using a keypad, followed by debugging, and the debugged program is written into the program memory chip.
-
The second is to use the assembly program of the development machine for assembly.
-
The third is to use a general-purpose microcomputer equipped with an assembly program for cross-assembly, and then transfer the target code to the development machine.
Additionally, high-level languages (such as C51) can be used to design microcontroller application programs. The source program of the high-level language edited in the PC is compiled and linked to form a target code file, which is then transferred to the development machine. This method has the advantages of short cycles and ease of portability and modification, making it suitable for developing more complex systems.
4.2 Traditional Development Methods of Microcontroller Application Systems
Microcontroller development systems are also known as development machines or emulators. The purpose of emulation is to use the resources of the development machine (CPU, memory, and I/O devices, etc.) to simulate the CPU, memory, and I/O operations of the microcontroller application system to be developed (i.e., the target machine) and track and observe the operating state of the target machine.
Emulation can be divided into software simulation emulation and online emulation of the development machine. Software simulation emulation is cost-effective and convenient to use, but it cannot perform real-time debugging and fault diagnosis of the application system hardware. Below, only the method of online emulation will be introduced.
1. Development Using Standalone Emulators
Standalone emulators are made from the same type of microcontroller used in the application system, configured with LED displays and simple keyboards. This development system can perform online emulation of the microcontroller application system without the support of a general microcomputer system, facilitating debugging and modification of application software on-site.
Additionally, this development system is equipped with a serial interface, allowing it to connect with general microcomputer systems. Thus, the source program can be edited, assembled, and online emulated using the software provided by the general microcomputer system. The debugged target program (i.e., machine code) can then be sent to the emulator for program storage.
2. Development Using Non-Standalone Emulators
This type of emulator is constructed using a general microcomputer and emulator. The emulator is connected to the general microcomputer via serial communication. This development method requires support from the microcomputer, utilizing software provided by the microcomputer system for source program editing, assembly, and emulation debugging. Some emulator interfaces also come with EPROM writing sockets for writing the completed user application program into EPROM chips. Compared to the previous method, this development method is less convenient for modifying and debugging parameters on-site.
Both of these development methods involve removing the microcontroller chip and program memory chip from the target system during development, and inserting the emulator head from the development machine, effectively lending the microcontroller from the development machine to the target machine.
Once emulation debugging is completed without errors, the emulator head is removed, and the microcontroller chip is reinserted. The debugged program from the development machine is then stored in the EPROM
chip and inserted into the program memory socket of the target machine, allowing the target machine to operate independently.
4.3 Development of Microcontroller Development Methods
With the widespread adoption of microcontroller surface mount packaging and the rapid development of Flash memory technology, the traditional concepts of developing microcontroller application systems will be impacted.
Using new microcontroller application system development technologies allows the microcontroller to be installed on the printed circuit board first, and then the program can be downloaded to the target system via a PC.
For example, SST has launched the SST89C54
and SST89C58
chips, which have 20 KB
and 30 KB
of SuperFlash
memory, respectively. This memory allows for high-speed read/write capabilities and supports in-system programming (ISP) and in-application programming (IAP) functionalities.
First, the application program is edited, assembled (or compiled), and simulated on the PC, and then the target program is serially downloaded.
Microchip’s RISC structure microcontroller PIC16F87X
includes an online debugger ICD
function, and the company also provides a simple emulator and programmer with ICSP
functionality. Because the chip includes detection circuit logic, additional hardware emulators are not needed.
Through a serial cable connected to the PC (which includes the MPLAB-ICD
module with communication functionality and the MPLAB-ICD
head connected to the target board), emulation debugging of the target system can be completed.
-END-