Microcontroller can also be referred to as MCU or μ C, also known as single chip microcontroller, which integrates ROM, ram, CPU and I / O in the same chip for different applications. After years of continuous research and development, microcontroller has gone through 4-bit, 8-bit, 16 bit, 32-bit and even 64 bit. The maturity of products, as well as the number of manufacturers and the wide range of applications, is really unprecedented. At present, because of the early development and wide product line, the foreign manufacturers are leading in technology, while the local manufacturers are taking multi-function as the product orientation to win. However, it can not be denied that the price war of local manufacturers is the key factor threatening foreign investors.
Due to the improvement of manufacturing process, the price difference between 8-bit MCU and 4-bit MCU is almost the same, and 8-bit MCU has gradually become the mainstream of the market; At present, most of the 4-bit MCU are used in calculators, car meters, car anti-theft devices, pagers, wireless phones, CD player, LCD drive controllers, LCD games, children’s toys, scales, chargers, tire pressure meters, thermohygrometers, remote controls and point and shoot cameras; 8-bit MCU is mostly used in electric meter, motor controller, electric toy machine, variable frequency air conditioner, pager, fax machine, caller ID, telephone recorder, CRT display, keyboard and USB; 16 bit MCU is mostly used in mobile phone, digital camera, video recorder, etc; Most of 32-bit MCU are used in modem, GPS, PDA, HPC, STB, hub, bridge, router, workstation, ISDN telephone, laser printer and color fax machine; most of 64 bit MCU are used in high-level workstation, multimedia interactive system, advanced video game (such as Sega’s Dreamcast and Nintendo’s Gameboy) and advanced terminal, etc.
In terms of architecture, MCU development can be divided into two main streams: RISC (such as Holtek ht48xxx Series) and CISC (such as Huabang W78 Series). RISC (reduced instruction set computer) represents that all the instructions of MCU are composed of some simple instructions. Simple instructions represent the circuit of MCU, which can be optimized as far as possible, and improve the execution speed, so that the time required for an instruction is relatively reduced to the shortest. Holtek’s ht46xx (A / dmcu Series), ht47xx (r to f MCU Series), ht48xx (general I / O MCU Series) and ht49xx (LCD MCU Series) are designed with RISC structure. No matter RISC or CISC (complex instrumentation set computer), the purpose of MCU design is to serve human beings. For RISC, because of the simplification of instruction set, many tasks must combine simple instructions, while for more complex tasks, they need to be executed by the compiler, and CISC is the best choice MCU has more instruction sets provided by hardware, so many tasks can be replaced by one or several instructions, so the work of compiler is reduced a lot.
Figure 1: MCU architecture block diagram.
Program memory (program ROM) is a read-only but not writable memory unit in the microcontroller. This memory is mainly used to place the program developed by the user, and its nature is the data that is not changed or never changed. The action of the microcontroller is based on the program instructions stored in this area. In 8-bit single chip, the common program memory capacity is 0.5K, IK, 2K, 4K and 8K, while the program memory commonly used in microcontroller has the following ways, as shown in Table 1:
Table 1: there are several ways in the program memory of microcontroller.
In addition, the part of program confidentiality, whether it is encryption or fuse blow protection, is to prevent the program from being peeped and stolen by unauthorized users (such as anti assembly program, content modification, stealing program, etc.). Program secrecy is only used on OTP, windowed packaging, EEPROM and flash ROM, because these ICs can read program code back and forth by means of the burner, and there is no need for program secrecy in the mask version. Random access memory (RAM), also known as read write memory, is often used to store data temporarily or during program execution. It is widely used. Taking Holtek 8-bit microcontroller as an example, its capacity has 64, 96, 160 and 224 bytes.
The accumulator is the operation center of MCU, 80% of the instructions are related to the accumulator; data can be stored in the accumulator until the bus or other units are ready to accept it, or until the program needs it.
Register is used to store data temporarily in MCU. The function of each buffer is different, but it has a common feature, that is, it can read / write directly. Because it is located in MCU, it reduces some unnecessary waiting and addressing time. In addition, the I / O port of some MCU also uses the buffer type for direct access control.
Stack and stack pointer
Stack and stack pointer, stack is just like a plate, one by one from the bottom to the top, and when it is taken out, it is taken from the top to the bottom and cannot be drawn out from the middle, so it is also called “last in first out queues”. The functions are as follows;
One. Temporarily store the value of PC (program count), which is suitable for “subroutine call”, or temporarily store the value of PC when interruption occurs;
Two. It can be used as a buffer, which is completed by push and pop;
Three. For some MCU, the number of stack levels is fixed (such as Holtek μ C Series), while for others, it can be customized. Operational logic unit
Arithmetic logic unit (ALU) is used to execute arithmetic instructions and logical judgment. Besides generating results, it also generates related flags (zero, carry, borrow, status). Every MCU is not exactly the same. Especially, for carry flag, you must check the instruction explanation table.
I / O port
In the single chip microcomputer application system, the expansion of I / O is not the purpose, but to provide an input / output channel for external devices, as a communication channel between the outside world and MCU. For example, it is connected to keyboard, display, drive switch control or measurement, etc.; when I / O expansion, it is necessary to consider the hardware circuit characteristics of peripheral equipment connected with it, such as potential matching, interference suppression, driving ability (such as source, sink ability), etc.
There are many kinds of circuits in the I / O port of microcontroller, among which the output / input direction can be set in bit units by software. Each port is equipped with high current and high voltage buffer to directly drive LED and high power transistor, and to input analog signal.
The timers, such as the time counter and the timers, are provided with several different time bases of the MCU through the frequency division circuit by the external oscillation crystal. It is often used to:
One. Time base of clock (such as 1sec, 500ms, 62.5ms, 15.625ms, etc.);
2、 Time base of PWM (pulse width modulation);
Three. Key SCAN;
5、 Frequency youtput;
Six. Pulse Reading;
Seven. Apo (auto power off), etc. Counter
The event counter is dedicated to accumulating the number of external events, which may be pulse or other data, and can also be used to generate the correct time delay. It is often used to:
1、 Another time base with fixed frequency; 2. Counter; 3. Another immediate interrupt input;
4、 Speed meter, tachometer. Interrupt is used to deal with immediate events or priority events. It is responsible for time counter timeout interrupt and external events generating interrupt request. The interrupt processing system of most microcontrollers is multi-layer, with interrupt priority circuit to determine the order. It is often used to:
1、 MCU is in passive standby state (halt stop) and wakeup by external signal;
2、 Need to deal with immediately (sensor, switch, alarm, power failure alarm); third, need a fixed interval to deal with (display, key scan, read time clock); peripheral resources on the microcontroller
After looking at the basic architecture of so many microcontrollers, let’s continue to understand what peripheral resources can be added to microcontrollers to expand and extend their functions.
Serial I / O
The purpose of serial I / O in microcontroller is to provide communication channel for external device
◆UART（Universal Asynchronous Receiver Transmitter）：Intel，Atmel;
◆USART（Universal Synchronous/Asynchronous Receiver Transmitter ）：Siemens;
◆SPI（Serial Peripheral Interface）：Motorola;
SCI (serial communications interface): This is an enhanced version of UART;
◆I2C bus（lnter Integrated Circuit bus）：Philips;
◆Microwire/ Plus:National SEMIconductor;
On the display interface, LCD (liquid crystal display) is a commonly used display device. For example, its trace can be found in some multi-functional phones, digital thermometers, pagers, mobile phones and handheld game machines. Therefore, the microcontroller with LCD drive circuit is widely used. There are two kinds of drive modes: segment and dot matrix. For example, the popular pet egg is the LCD display with dot matrix; In addition, Holtek ht49xx series also provides LCD driver microcontrollers.
LCD display in the environment without light source or backlight, we can not read the content of the display, and VFT display can provide high brightness, and color change visual effect, often used in advanced household appliances, such as: DVD player, DSP equalizer. VFT (vacuum fluorescent tube) driver is one of the most important resources in the selection of microcontrollers for products that require dazzling output effect.
OSD is one of the indispensable functions for the Humanized Interface of TV and monitor. The display circuit of OSD (on screen display) is to receive the H-sync and V-sync signals, and then send out the screen information through RGB and blanking. The display color can be up to eight.