The process of a microcontroller automatically completing the tasks assigned to it is the process of the microcontroller executing a program, which means executing instructions one by one. An instruction is a command that specifies the various operations the microcontroller is to perform, determined by the instruction set assigned by the designer. Each instruction corresponds to a basic operation; the total set of instructions that a microcontroller can execute is known as its instruction set. Different types of microcontrollers have different instruction sets. To enable the microcontroller to automatically complete a specific task, the problem to be solved must be compiled into a series of instructions (these instructions must be recognizable and executable by the selected microcontroller). This collection of instructions is called a program, which needs to be stored in a component with storage capability—memory. Memory consists of many storage units (the smallest storage unit), similar to how a building is made up of many rooms. Instructions are stored in these units, and retrieving and executing the instructions from the units is akin to assigning a unique room number to each room in the building. Each storage unit must also be assigned a unique address, known as the address of the storage unit. Thus, once the address of the storage unit is known, it can be located, and the instructions stored there can be retrieved and executed.

Programs are usually executed sequentially, so the instructions in the program are also stored in sequence. When the microcontroller executes the program, it must be able to retrieve and execute these instructions one by one, which requires a component that can track the address of the instructions. This component is the program counter (PC), which is included in the CPU. When the program starts executing, the PC is assigned the address of the first instruction in the program, and then each command to be executed is retrieved. The contents of the PC will automatically increment, with the increment determined by the length of the current instruction, which could be 1, 2, or 3, to point to the starting address of the next instruction, ensuring the sequential execution of instructions.
A single-chip microcomputer, abbreviated as microcontroller, is a typical embedded microcontroller, commonly represented by the abbreviation MCU. It was initially used in the industrial control field. The microcontroller evolved from a chip with only a dedicated CPU. The original design concept was to integrate a large number of peripheral devices with the CPU into one chip, making the computer system smaller and easier to integrate into complex control devices that have strict size requirements. The INTEL Z80 was the first processor designed according to this concept, after which the development of microcontrollers and dedicated processors diverged.
Early microcontrollers were all 8-bit or 4-bit. The most successful was INTEL’s 8031, which received great acclaim for its simplicity, reliability, and good performance. Subsequently, the MCS51 series microcontroller system was developed based on the 8031. Microcontroller systems based on this system are still widely used today. With the increasing demands in the industrial control field, 16-bit microcontrollers began to appear, but due to their less-than-ideal cost-performance ratio, they did not gain widespread application. After the 1990s, with the rapid development of consumer electronics, microcontroller technology saw significant advancements. With the widespread application of the INTEL i960 series, especially the later ARM series, 32-bit microcontrollers quickly replaced 16-bit microcontrollers in high-end positions and entered the mainstream market. Moreover, the performance of traditional 8-bit microcontrollers has also improved rapidly, with processing capabilities increasing hundreds of times compared to the 1980s. Currently, high-end 32-bit microcontrollers have clock frequencies exceeding 300MHz, with performance rivaling that of dedicated processors from the mid-1990s, while the prices of ordinary models have dropped to 1 dollar, and the highest-end models are only 10 dollars. Contemporary microcontroller systems are no longer developed and used solely in bare-metal environments; a large number of dedicated embedded operating systems are widely used across the entire range of microcontrollers. In high-end microcontrollers that serve as the core processors for handheld computers and smartphones, specialized Windows and Linux operating systems can even be directly utilized.
Microcontrollers are more suitable for use in embedded systems than dedicated processors, which is why they are the most widely applied. In fact, microcontrollers are the most numerous computers in the world. Almost every electronic and mechanical product used in modern human life integrates microcontrollers. Mobile phones, telephones, calculators, household appliances, electronic toys, handheld computers, and computer peripherals such as mice all contain 1-2 microcontrollers. Personal computers also have a considerable number of microcontrollers at work. Cars typically contain more than 40 microcontrollers, and complex industrial control systems may have hundreds of microcontrollers working simultaneously! The number of microcontrollers not only far exceeds the total of PCs and other computing devices but is even greater than the human population.
Microcontrollers also use modules similar to those in computers, such as CPU, memory, and parallel buses, as well as storage devices that function like hard drives. The difference is that the performance of these components is generally much weaker than that of our home computers, but the price is also low, generally not exceeding 10 yuan. It is sufficient to use them for controlling relatively simple tasks. We can see their presence in modern appliances like fully automatic washing machines, range hoods, VCDs, etc.! They mainly serve as the core components for control.
It is a real-time control computer that operates online, meaning it requires strong anti-interference capabilities and low costs, which is a major distinction from offline computers (such as home PCs).
Microcontrollers operate based on programs, which can be modified. Different programs can achieve different functions, especially unique functions that other devices find difficult to accomplish. If a not very complex function were to be implemented using the 74 series developed in the 1950s or the CD4000 series from the 1960s, the circuit would certainly require a large PCB! However, if the series of microcontrollers successfully launched in the 1970s were used, the results would be drastically different! This is because microcontrollers can achieve high intelligence, high efficiency, and high reliability through the programs you write!
Since microcontrollers are sensitive to cost, the dominant software currently remains the low-level assembly language, which is the lowest-level language after binary machine code. Since it is so low-level, why is it still used? Many high-level languages have reached a level of visual programming, so why not use them? The reason is simple: microcontrollers do not have CPUs like home computers, nor do they have massive storage devices like hard drives. A small program written in a visual high-level language, even if it only contains one button, can reach sizes of dozens of kilobytes! This is not a problem for home PC hard drives, but it is unacceptable for microcontrollers. The utilization rate of hardware resources in microcontrollers must be very high, so although assembly language is primitive, it is still widely used. The same principle applies to running operating systems and application software from giant computers on home PCs; home PCs also cannot bear it.