10 Common Questions About MCU

Publisher:码字狂徒Latest update time:2013-03-04 Source: 21IC Keywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. What is a microcontroller?

Simply put, a single-chip microcomputer is a small computer system. To explain this issue clearly, we have to start with computers. When it comes to computers, you may immediately think of "monitor, mouse, keyboard", but these are not the core and key of a computer. The core of the computer is in the chassis on one side. Open the chassis and you can see that there are motherboards, hard drives, optical drives, etc. in the chassis. Look carefully at the motherboard, which has CPU, memory sticks, BIOS chips, and usually a 25-pin printer interface, etc. These components are connected to each other through the wires on the motherboard.

No matter how complex a computer is, it always consists of five parts: the arithmetic unit, the controller, the memory, the input/output interface, and the bus. Usually the arithmetic unit and the controller are made into a chip, that is, the CPU (central processing unit). On the computer motherboard, the memory stick and the BIOS chip are the memory, the 25-pin printer interface is the input/output device, and the bus is designed on the motherboard, that is, the line that connects the components to each other.

In some applications, people do not need computers to complete very complex calculations, but they hope that the computer is small, reliable and cheap. So people integrated all the five parts of the computer into a chip, that is, a chip can constitute an independent computer. Under the technical conditions at that time, this was a remarkable thing, so people named it "single-chip microcomputer" based on this feature.

If all the five parts needed to form a computer are integrated into one chip, will the chip be very large and expensive? Not really. If all the components on the motherboard shown in Figure 1 are integrated into one chip, it will of course be very expensive and may not be technically feasible. However, the functions required in many single-chip microcomputers do not need to be so powerful, so many single-chip microcomputers are very small and cheap. For example, the common single-chip microcomputers on the market have 8, 14, 16, 18, 20, 28, 40, 84 pins, and some even have only 6 pins. As shown in Figure 2, this is a 6-pin single-chip microcomputer released by Microchip. The prices range from a few yuan to tens or hundreds of yuan, and some varieties can even be as low as 1 yuan when ordered in large quantities.

People who have just come into contact with single-chip microcomputers often have a doubt: since people are already capable of making powerful computers, why do we still produce some computers with weak functions? In fact, the power is not the decisive factor in determining whether to produce, but the market demand is the key. For example, a computer used to control an electric box obviously does not need to use the powerful computing power of the "Pentium" chip. It only needs to perform very simple calculations, make a comparison, see if the temperature is within the control range, and then make corresponding controls.

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. Enthusiasts who learn 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.

2. How does a microcontroller work?

The working process of the single-chip microcomputer is a process of constantly "fetching instructions-analyzing instructions-executing instructions". The program of the single-chip microcomputer is stored in the program memory in the form of instructions one by one. After the single-chip microcomputer starts working, it starts to fetch instructions from a specific location in the program memory, and then the controller inside the single-chip microcomputer analyzes the instructions. According to the instructions, it performs one or more of the basic operations such as "fetching numbers, sending numbers, arithmetic operations, logical operations, and jumping". These operations are completed in a specified cycle. After execution, it fetches instructions from the next memory unit and repeats the previous operation (of course, the specific content of these operations to be performed may be different from the last time), and repeats this process until the power is turned off. The "specific memory location" and "specified cycle" mentioned here are related to the model of the single-chip microcomputer. The following is an example of the 51 series single-chip microcomputer.

There is a register called PC in the 51 series microcontroller (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 according to the value in the PC register. Therefore, after the power is turned on, the first instruction will be fetched 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 microcontroller, an instruction may occupy one byte, two bytes or three bytes. If the first instruction is a single-byte instruction, after the first instruction is fetched, the value of PC will become 0001H. Therefore, after the first instruction is executed, the second instruction will be fetched 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, so that the value in PC points to the address unit where the next instruction to be executed is located. This jump can be either forward, 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 51 single-chip microcomputers, there are three possible instruction execution times: single cycle, double cycle and four cycle. No matter how much work an instruction needs to do, it must be completed within the specified time.

3. What is the function of a microcontroller program? How to write it? How to write it into a microcontroller?

The purpose of the microcontroller program is to make the microcontroller "obedient" and complete a series of actions according to the predetermined design, and ultimately achieve a specific function.

For example, if you use a single-chip microcomputer to control a running light, after the power is turned on, the light will light up for the first time, then delay for a while, light up for the second time, then delay for a while, light up for the third time..., after a delay, it will light up again for the first time, and repeat this cycle endlessly. There are some problems here: how many lights should be lit for the first time, how long should the delay be, how many times should different lights be set in a cycle..., these determine the pattern of the running light and the speed of the flow, and the single-chip microcomputer obviously has no self-judgment ability, it must rely on people to "assign" tasks to it, and it will execute them in sequence according to people's designs.

To make the microcontroller "obedient", we need to issue commands in a language that the microcontroller can understand. The language that the microcontroller can understand is called "instructions". The instructions that any type of microcontroller can accept are limited. The number of instructions for the 51 microcontroller is 111, while the number of instructions for the PIC microcontroller is only 35. Each instruction completes a basic action. In order to complete a specific function, people need to arrange and combine these instructions into an instruction sequence, which is a program.

There are two forms of instructions: machine language and assembly language. Take 51 as an example. If you want to make the P1.0 pin low, it is expressed in machine language as C2H 90H. Put these two numbers into the program memory of the microcontroller. After the microcontroller executes, the P1.0 pin can be turned to a low level; and if you want to make the P1.0 pin high, it is expressed in machine language as D2H, 90H. As for why these two numbers are used, there is no need to investigate. This is stipulated by the design engineer who designed this chip. We cannot change it, but can only learn from it.

C2H, 90H is an instruction. Obviously, such instruction form is difficult to remember and programming is also very difficult, so people use "mnemonics" to replace these numbers. For example, the mnemonic of C2H, 90H is CLR P1.0, and the mnemonic of D2H, 90H is SETB P1.0. Since the mnemonics use the abbreviations of English letters and have certain meanings, they are easier to remember and use than digital instructions. Using mnemonic instructions to write programs is called "assembly language source program". However, the assembly language source program cannot be directly sent to the microcontroller. The program written using mnemonic instructions must eventually become such as: C2H, 90H, D2H, 90H, and this form of instruction can be sent to the program memory of the microcontroller. The process of converting mnemonic instructions into digital instructions is called "assembly". There are two methods of assembly. One is "manual assembly", which means people find the digital form of the assembly instructions by looking up a table and then write them down; the other is "machine assembly", which means after writing the assembly language source program, use a computer software to process these source programs to obtain a digital instruction sequence. This instruction sequence is usually called "machine code", which is the code that can be directly executed by the machine. [page]

The digital instruction sequence obtained after the machine is assembled is saved on the disk in the form of a file. The extension of this file is generally HEX, which is commonly known as a HEX file. After obtaining the HEX file, it can be written into the program memory. To write the program into the chip, a special device called a "programmer" is usually required. Run the matching programming software on the computer, and then open the HEX file in this software to write it into the chip. With the development of technology, there are more and more programming methods, but the general concept is this. The specific details will be answered in another question "What is a microcontroller programmer?"

4. What does the "XX bit" in 8-bit, 16-bit, and 32-bit microcontrollers mean?

8-bit, 16-bit, and 32-bit refer to the "word length" of the microcontroller, that is, the length of the data involved in an operation. This bit refers to the binary bit. Taking 8-bit as an example, the expression range of 8-bit binary is 0000, 0000~1111, 1111 is 0~255 in decimal, that is, the maximum data involved in each operation cannot exceed 255. The word length of a 16-bit machine is 16 bits, and its data expression range is 0~65535, that is, the maximum data involved in each operation cannot exceed 65535; the word length of a 32-bit microcontroller is 32 bits, and its data expression range is 0~4294967295, that is, the maximum data involved in each operation cannot exceed 4294967295.

8-bit, 16-bit, and 32-bit are closely related to the performance of single-chip microcomputers. Usually, the performance of 32-bit microcomputers is higher than that of 16-bit microcomputers, and the performance of 16-bit microcomputers is higher than that of 8-bit microcomputers. Why is this so? This needs to be analyzed from two aspects. First, the number of bits is different, and the operation efficiency is different. For an 8-bit microcomputer, since each number in an operation cannot exceed 8 bits, even an operation such as 100+200=300 cannot be completed at one time, because 300 exceeds the maximum range that 8 bits can express (255). Therefore, to operate such an equation, it is necessary to write a program to complete the operation step by step and finally synthesize it to get a correct result. If a 16-bit microcomputer is used for operation, then one operation is enough. Obviously, the time required for step-by-step completion is much longer than the time required for single-step completion. By the same token, when the result or intermediate value of a certain operation is greater than 65535, a 16-bit microcomputer cannot operate at one time and must implement it step by step, while a 32-bit microcomputer can complete it at one time. Second, commercial factors. Generally speaking, the higher the computing power, the stronger the performance of the microcontroller. Of course, people can accept a higher price. With price space, manufacturers will usually provide more other functions in these chips to further improve the overall performance of the chip.

Among typical single-chip microcomputers, the 80C51 series, PIC series, and AVR series are all 8-bit single-chip microcomputers; the 80C196 and MSP430 series are 16-bit machines; and the currently very popular ARM series is a 32-bit machine.

5. What are microcontroller programmers, emulators, writers, and download cables? What are their uses?

The microcontroller programmer is a tool used to write program code into the memory chip or the internal part of the microcontroller. When the chip is in the form of a dual in-line plug, it can be burned by directly inserting it into the socket. Another method is to use a download cable. With the advancement of technology, more and more microcontroller chips begin to support the "ISP" function, that is, In System Programmer, online programming technology. Using this technology, a blank (unprogrammed) chip is directly soldered on the printed circuit board, and the chip can be programmed using a few pins reserved in advance. There is no need to remove the chip and put it on the programmer. Therefore, this brings great convenience to small-batch production and saves the purchase of expensive adapters.

6. What are the necessary hardware equipment for self-learning microcontrollers?

In order to learn microcontrollers, in addition to a computer, you also need the following equipment.

1. Experimental board

If you know nothing about single-chip microcomputers, it is a good choice to make or buy an experimental board. Usually, some common devices such as switches, LED indicators, digital tubes, various interface chips, etc. are designed on the experimental board. Through programming exercises on these devices, you can gradually master the programming technology of single-chip microcomputers.

2. Simulation machine

The purpose of the simulator is to replace the MCU chip on the circuit board. The simulator communicates with the PC through serial ports, USB interfaces, etc., receives instructions from the PC control software, and executes programs in various ways such as single-step, process single-step, and full-speed operation. When executing programs in single-step or process single-step mode, the results of the execution can be fed back to the PC control software for display after each execution of the program. Since it is necessary to clearly know what the results will be after each instruction is executed when programming the MCU, and to find out whether the actual results after the operation are consistent with the expected results, the simulation function can play an important role in the study and development of MCUs.

3. Programmer or download cable

Its purpose is to write the code into the microcontroller chip. For learners, if you have a simulator, you don't need a programmer or download cable for the time being, because you can do experiments with a test board and simulator. However, it is recommended to configure one, so that you can understand all aspects of microcontroller development.

4. Multimeter, soldering iron and other electronic production tools

Microcontroller development is not a simple programming. So far, there are few pure "microcontroller programmers". Developers are usually required to be familiar with both software and hardware. Therefore, these electronic production work still needs to be equipped.

It should be noted that the simulators, experimental boards, download cables or programmers mentioned here are general concepts and do not involve specific products. There are also some products on the market that integrate part or all of the experimental boards, simulation functions, download or programming functions into one board during design to form a complete experimental system.

7.What are the commonly used single-chip microcomputers in China?

1.80C51 and its compatible series

(1) 80C51 series, which is the most basic series. It includes 80C31, 80C51, 87C51, 80C32, 80C52, 87C52 and other chips. Although these chips are basically no longer used, they are the basis of subsequent chips. Among them, the 80C31 microcontroller has no ROM inside, the 80C51 has a one-time 4K PROM, and the 87C51 has a 4K EEPROM. The internal RAM of these chips is 128 bytes. The internal RAM of the last three chips is 8K, and the internal ROM of the last two chips is 8K bytes.

(2)80C51 compatible series

These chips are usually compatible with the 51 series MCU at the instruction level, but they have expanded many new functions. The most common ones are as follows.

The main features of STC89 series microcontrollers are: programming the microcontroller directly through the serial port; programmable to run at multiple speeds; ultra-low power consumption; built-in watchdog; internal FLASH ROM can be used as EEPROM to save data when power is off. [page]

The main features of STC12 series microcontrollers are: single clock cycle, operating frequency 0~35M, equivalent to ordinary 80C510~420M; wide voltage range; low power consumption; built-in E2PROM function on the chip; built-in hardware watchdog; general I/O ports can be set to four working modes and can "spit out" current in strong pull-up mode.

The main features of Philips' LPC series are: built-in RC oscillator, no external oscillation device is required when selecting the RC oscillator; all ports have 20mA LED driving capability; and a wide operating voltage range.

The main features of the C8051F series are: one machine cycle is only one clock cycle; an interrupt source is added; there is an internal independent clock source or an external clock, and the internal and external clocks can be switched when the program is running. Each I/O port pin can be set to push-pull or open-drain output. The most unique feature of the C8051F series microcontroller I/O port is the addition of a digital cross switch, which can be used to direct internal digital system resources to the P0, P1 and P2 port I/O pins. Many models of chips in this series have functions such as ADC, DAC, PCA, etc.

2.PIC series

The development idea of ​​PIC microcontroller is different from that of 51 microcontroller. It does not simply pile up functions, but starts from reality, attaches importance to the performance and price ratio of products, relies on the development of multiple models to meet the application requirements of different levels; streamlined instructions greatly improve its execution efficiency. There are currently hundreds of varieties of PIC10, PIC12, PIC16, and PIC18 series. Take the PIC16F676 chip as an example. The chip has a built-in 1K word FLASH ROM, 128 bytes EEPROM, 64 bytes RAM, 8-channel 10-bit AD converter, built-in oscillator with an accuracy of up to ±1%, extremely low power consumption, and a wide operating voltage range. Such a high-performance 14-pin chip costs less than ¥7, and the cost performance is quite high.

3.AVR series

AVR series microcontrollers are enhanced RISC structure microcontrollers, and their main features are: fast speed, one machine cycle is only one clock cycle; rich variety, similar to the PIC series, relying on the development of multiple models to meet different levels of application requirements; support ISP, IAP functions, online programming, convenient remote maintenance; wide working range, strong anti-interference ability. Take the ATMEGA8 chip as an example, the chip has built-in 8K Flash ROM, 512 bytes EEPROM, 1K bytes RAM, 8-channel 10-bit AD, and built-in RC oscillator. Such a high-performance 28-pin chip costs only about ¥7, and the cost performance is also quite high.

4. Others

Other commonly used single-chip microcomputers include: ST, EMC, Motorola, Samsung, etc. Some of these single-chip microcomputers are widely used in the market, but we did not focus on introducing them, because the content we introduced is mainly for amateurs. Although some chips are powerful and cost-effective, they are not for amateurs. Small batches of chips are difficult to buy, and the price of development tools such as emulators and C compilers is extremely expensive, so we will not introduce them here. If you are interested, you can search for relevant information on the Internet.

8.What is the approximate price of commonly used microcontrollers?

The prices of microcontrollers vary greatly, ranging from less than 1 yuan to tens of yuan or even hundreds of yuan. The following is a brief introduction to the prices of commonly used microcontrollers.

9. What are the commonly used software for microcontroller programming, simulation, and debugging?

Different types of microcontrollers require different development software. We will use the 80C51 series, PIC series and AVR series as examples to explain them respectively.

The writing of single-chip microcomputer programs does not require any special software, as long as it is a text editor software, such as the notepad and WORD that come with WINDOWS, but these software are not convenient to write. There are some better text editors to choose from, such as UltraEdit, PE2, etc. Of course, people most often use the editor that comes with the development software to write. Taking the 80C51 series single-chip microcomputer as an example, the most popular software is Keil software. Keil software is a comprehensive development tool with built-in editors, ASM assemblers, C51 compilers, debuggers and other parts.

10. Can you recommend some books or other tutorials for learning microcontrollers?

There are a lot of books on microcontrollers on the market. For beginners, it is generally better to choose the 80C51 series. If you have a clear work object, that is another matter.

Keywords:MCU Reference address:10 Common Questions About MCU

Previous article:Summary of matters needing attention in single chip microcomputer design
Next article:The difference between bus-type MCU and non-bus MCU

Recommended ReadingLatest update time:2024-11-17 02:49

A brief analysis of three ways to achieve low power consumption in MCU
  Today's electronic products have higher and higher requirements for low power consumption. The problem of product power consumption is a problem that often gives product designers headaches but has to face. The power consumption of a system with a single-chip microcomputer as the core is mainly composed of the power
[Power Management]
C program for DS18B20 of STC microcontroller
Since the speed of STC microcontroller is faster than 8051, it belongs to 1 clock/machine cycle high-speed microcontroller. The high speed is of course its advantage, but for transplanting traditional 8051 programs, it is necessary to modify the timing to realize a certain function. The following program is a simple d
[Microcontroller]
Detailed explanation of serial communication (51 single chip microcomputer)
Computer Serial Communication Basics With the widespread application of multi-microcomputer systems and the popularization of computer network technology, the communication function of computers is becoming increasingly important. Computer communication refers to the information exchange between computers and external
[Microcontroller]
Detailed explanation of serial communication (51 single chip microcomputer)
Design of Voice Perpetual Calendar Based on 51 Single Chip Microcomputer
1. Hardware Solution This circuit is controlled by AT89C52 single-chip microcomputer, which has thread function, low power consumption, and can work at 3V ultra-low voltage; the clock circuit is provided by DS1302, which is a high-performance, low-power, real-time clock circuit with RAM. It can timely record the year,
[Microcontroller]
Design of Voice Perpetual Calendar Based on 51 Single Chip Microcomputer
Design of proteus simulation program for humidifier based on 51 single chip microcomputer DHT11
hardware design Simulation diagram: LCD1602 is used as the display, temperature and humidity use DHT11, and the threshold is set by 3 buttons. When the temperature and humidity exceed the upper and lower limits, the respective relays will be triggered; programming #include "common.h" #include "lcd1602.h" #include "d
[Microcontroller]
Design of proteus simulation program for humidifier based on 51 single chip microcomputer DHT11
Detailed explanation of the asynchronous communication program between two PIC microcontrollers
1 PIC1 microcontroller programming (sending part) #include /*This program implements the asynchronous communication function between two MCUs. This program is the sending part*/ unsigned char tran ; /*define an array to store the sent data*/ unsigned char k, data; /*define general register*/ cONST char table
[Microcontroller]
MCU sends text messages to mobile phones
 With the rapid development of science and technology and the continuous improvement of people's living standards, the penetration rate of mobile phones is getting higher and higher, the updates are getting faster and faster, and the prices are getting cheaper and cheaper. Because the wireless network coverage of mobi
[Microcontroller]
How to realize serial communication between PC and AT89C51 microcontroller
In the data acquisition and real-time control system based on single-chip microcomputer, the command and data transmission between the computer and the single-chip microcomputer is carried out through the RS-232 interface in the computer, and the computer can be used to monitor and control the production site. Since th
[Microcontroller]
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号