Detailed explanation of microcontroller principles and applications
[Copy link]
Microcontrollers can be found everywhere in our lives, so what is the principle of microcontrollers ? How does it work ? What are the applications of microcontrollers ? Today I will share with you the principles and applications of microcontrollers.
Principle of single chip microcomputer
The single-chip microcomputer is composed of an arithmetic unit, a controller, a memory, and input and output devices. How does a single-chip microcomputer work ? Let's take a look at the working principle of a single-chip microcomputer:
The working process of a single-chip microcomputer is a process of continuously "fetching instructions - analyzing instructions - executing instructions".
The program of the microcontroller is stored in the program memory in the form of instructions one by one. When the microcontroller starts working, it starts fetching instructions from a specific location in the program memory.
The controller inside the microcontroller then analyzes the instructions and performs one or more of the basic operations such as "data fetching, data sending, arithmetic operations, logical operations, and jumps" according to the instruction requirements. These operations are completed within a specified cycle.
After executing these operations, the next memory unit is used to fetch instructions and the previous operations are repeated ( of course, the specific content of the operations to be performed may be different from the last time ) , and this process is repeated continuously until the power is turned off.
The "specific memory location" and "specified cycle" mentioned here are related to the model of the microcontroller. The 51 series microcontroller is used as an example to illustrate below.
There is a register called PC in the 51 series microcontrollers ( a container for storing numbers ) . After the microcontroller is reset, the content of this register is set to 0000H . The controller inside the microcontroller always fetches instructions from the corresponding program memory unit based on the value in the PC register .
Therefore, after booting up, the first instruction will be taken from the 0000H unit, analyzed and executed. At the same time, the PC value will be adjusted accordingly to point to the location of the next instruction to be executed. Where is the location of the next instruction ? For the 51 single-chip microcomputer, an instruction may occupy one byte, two bytes or three bytes. If the first instruction is a single-byte instruction, after taking the first instruction, the value of PC will become 0001H . Therefore, after the first instruction is executed, the second instruction will be taken from the 0001H unit to execute, and so on.
If the program is executed sequentially, the value of PC will always increase. If there is a jump instruction in the program, the instruction will affect the value in PC , making the value in PC point to the address unit of the next instruction to be executed. This jump may be positive, such as jumping from 0000H to 0030H , or reverse, that is, jumping back, such as jumping from 200H to 100H . It is precisely because instructions can affect the value in PC that programs can implement various functions such as "branching" and "looping".
So, how long does it take to execute an instruction ? For the 51 single -chip microcomputer, there are three possible instruction execution times: single cycle, double cycle and four cycles. No matter how much work an instruction requires, it must be completed within the specified time.
Well, that's all about the principles of single-chip microcomputers, so what are the applications of single-chip microcomputers ?
Microcontroller application areas
Single-chip microcomputers are used everywhere in people's lives and in industrial and agricultural production equipment, such as various timing devices, automatic control devices, etc. Almost every electronic and mechanical product used in modern human life is integrated with a single-chip microcomputer. Mobile phones, telephones, calculators, household appliances, electronic toys, PDAs, mice and other computer accessories are equipped with 1-2 single -chip microcomputers.
Enthusiasts who study single-chip microcomputers should pay attention to observing things and find occasions around them where single-chip microcomputers can be used, so as to apply the knowledge they have learned to practice. For example, using single-chip microcomputer technology to transform traditional electromechanical equipment and using single-chip microcomputers to replace PLCs in specific occasions have broad application prospects ; for example, using single-chip microcomputers to control electric fans, range hoods, air conditioners, etc., so as to produce controllers with more powerful functions and universal applications, is also worth trying.
|