▮ Introduction of Microcontroller
MCU is short for Microcontroller Unit. It appropriately reduces CPU frequency and specifications, and integrates memory, counter, USB, A/D conversion, UART, PLC, DMA and other peripheral interfaces, and even LCD drive circuits, into A single chip. The form of chip level computer, do different combination control for different application occasions, such as mobile phones, PC peripheral, remote control, automotive electronics, industrial stepper motor, robot arm control, etc., can be seen in the MCU figure.
▮ A brief history of MCU development
The history of MCU is not long, but its development is very rapid. Its generation and development and microprocessor (CPU) generation and development are roughly synchronous, since 1971 The United States Intel company first launched 4 microprocessors, and its development so far can be roughly divided into 5 stages. The following microcontroller development to Intel corporation as a representative is to be introduced.
From 1971 to 1976
The primary stage of MCU development. In November 1971, Intel company first designed the integrated degree of 2000 transistors/piece of 4-bit microprocessor Intel 4004, and equipped with RAM, ROM, and shift register, constituting the first MCS-4 microprocessor, and then launched the 8-bit microprocessor Intel 8008, And 8-bit microprocessors from various other companies.
From 1976 to 1980
Low-performance MCU stage. The MCS-48 series introduced by Intel corporation in 1976 is represented by a monolithic structure that integrates an 8-bit CPU, 8-bit parallel I/O interface, 8-bit timing/counter, RAM, and ROM into a semiconductor chip. Although its addressing range is limited (no more than 4 KB), and there is no serial I/O, RAM, and ROM capacity is small, the interrupt system is relatively simple, but the function can meet the general industrial control and intelligent instruments, meters, and other needs.
From 1980 to 1983
High-performance single-chip microcomputer stage. This phase of the introduction of a high-performance 8-bit microcontroller with serial port, multistage interrupt processing system, and a number of 16-bit timers/counters. The capacity of RAM and ROM on the chip is increased, and the addressing range can reach 64 KB. There are also A/D conversion interfaces in individual chips.
16-bit MCU stage. In 1983, Intel corporation launched a high-performance 16-bit MICROcontroller MCS-96 series, because of its use of the latest manufacturing technology, the chip integration was as high as 120,000 transistors/piece.
In the 1990 s
MCU in integration, function, speed, reliability, application fields, and other all-around development to a higher level.
▮ Microcontroller classification and application
MCU can be divided into two types according to its memory type: ROM without a chip and ROM with a chip. The chip without in-chip ROM, must be connected to the EXTERNAL EPROM can be used (typical for 8031); The chip with on-chip ROM type is divided into in-chip EPROM type (typical chip is 87C51), MASK in-chip MASK ROM type (typical chip is 8051), in-chip Flash type (typical chip is 89C51) and so on.
The use can be divided into the general type and special type; According to the width of the data bus and the length of data bytes that can be processed at one time, it can be divided into 8, 16, and 32-bit MCU.
At present, the domestic MCU application market is the most extensive in the consumer electronics field, followed by the industrial field, and automotive electronics market. Consumer electronics include home appliances, televisions, game consoles, and audio and video systems. Industrial areas include smart homes, automation, medical applications, and new energy generation and distribution. The automotive field includes automotive powertrain and safety control systems.
Figure to MCU.
▮ The basic function of MCU
For the vast majority of MCUs, the following functions are the most common and basic. They may be described differently for different MCUS, but they are essentially the same:
1, TImer: Although there are many types of TImer, they can be divided into two categories: Class is a fixed time interval TImer, that is, the timing of the time is set by the system, the user program cannot control, the system only provides several fixed time interval to the user program to choose, such as 32 Hz, 16 Hz, 8 Hz, etc., are common in this kind of TImer in four MCU, thus can be used to realize clock, TImer, and other related functions.
The other type is a Programmable Timer. As the name implies, the timing of this type of Timer can be controlled by the user’s program in the following ways: Clock source selection, Prescale selection, and prefabricated number setting, some MCUS have all three at the same time, while others may have one or both. This type of Timer application is very flexible, the actual use is also variable, one of the most common applications is to use it to achieve PWM output.
Since the clock source can be selected freely, such timers are generally combined with Event counters.
2, IO ports: Any MCU has a certain number of IO ports. Without IO ports, MCU would lose the channel to communicate with the outside world. The I/O port can be classified into the following types:
- Pure input or pure output: This type of IO port is determined by MCU hardware design and can only be input or output. The software cannot be used for real-time settings.
- Read and write I/O ports: For example, the I/O ports on MCS-51 belong to this type of I/O port. When executing the IO interface command, it is the input interface. When the write IO port command is executed, it automatically becomes the output port.
- Programming to set the input and output direction: the input or output of this IO port is set by the program according to the actual needs. The application is flexible and can realize some bus-level applications, such as I2C buses, various LCDs, LED Driver control buses, etc.
For the use of IO ports, it is important to keep in mind that: for input ports, there must be a clear level signal to ensure that no floating (which can be achieved by adding pull-up or pull-down resistors); For the output outlet, the state level of its output must take into account the external connection, and ensure that there is no pulling current or filling current in the Standby or static state.
3, External interrupt: External interrupt is also the basic function of most MCU. It is generally used for real-time signal triggering, data sampling, and state detection. The interrupt modes are as follows: rising edge triggering, falling edge triggering, and level triggering. The external interrupt is generally realized through the input port. If it is an IO port, the interrupt function will be enabled only when it is set to input. If it is an outlet, the external interrupt function is automatically turned off (with some exceptions in ATMEL’s ATiny series, the interrupt function can also be triggered at the outlet). The applications of external interrupts are as follows:
- External trigger signal detection: one is based on real-time requirements, such as SCR control, and sudden signal detection and the other is the need to save electricity.
- Signal frequency measurement: In order to ensure that the signal is not missed, the external interrupt is the most ideal choice.
- Data decoding: in the field of remote control applications, in order to reduce the design cost, it is often necessary to use software to decode all kinds of coding data, such as Manchester and PWM coding-decoding.
- Key detection and system wake-up: For the MCU that enters the Sleep state, it generally needs to wake up through external interrupt. The most basic form is the key, and the change in level is generated by the action of the key.
4, Communication interface: The communication interface provided by MCU generally includes SPI interface, UART interface, I2C interface, etc., which are described as follows:
- SPI interface: This kind of interface is the most basic communication mode provided by most MCU. Its data transmission is controlled by the synchronous clock. Signals include SDI(Serial data input), SDO(serial data output), SCLK(serial clock), and Ready signal. In some cases there may not be a Ready signal; This type of interface can work in Master or Slave mode. In a common parlor, it depends on who provides the clock signal. The clock provider is Master, and the clock provider is Slaver.
- Universal Asynchronous Receive Transmit (UART): a basic Asynchronous transmission interface. It has two signal lines: Rx and Tx. The basic data format is as follows: Start Bit + Data Bit(7-bits/8-bits) + Parity Bit(Even, Odd or None) + Stop Bit(1-2bit). The amount of time a bit of data takes is called the Baud Rate. For most MCU, data Bit length, data check mode (parity check, even check or no check), Stop Bit length and Baud Rate can be flexibly set by the program. The most common way of this kind of interface is to communicate with the serial port of the PC.
- I2C interface: I2C is a data transmission protocol developed by Philips. It also uses two signals: SDAT(serial data input and output) and SCLK(serial clock). The biggest advantage is that multiple devices can be connected to the bus and identified and accessed by address. One of the biggest advantages of the I2C bus is that it is very convenient to use software to realize it through the IO port. The data rate transmitted by the I2C bus is completely controlled by SCLK, which can be fast or slow, unlike the UART interface, which has strict rate requirements.
5, Watchdog: The Watchdog is also a basic configuration of most MCUS (some 4-bit MCUS may not have this function). The Watchdog of most MCUS can only allow the program to reset it, but not to close it (some are set when the program burns, such as Microchip PIC series MCUS). And some MCU is through a specific way to decide whether to open, such as the Samsung KS57 series, as long as the program access the Watchdog register, it will automatically open and can not be closed again. Generally speaking, the reset time of the watchdog can be set by the program. The most basic use of a Watchdog is to provide a self-healing capability for the MCU to crash due to an unexpected failure.
▮ The world’s mainstream microcontroller manufacturers
(Ranked in no particular order, sorted as mainstream manufacturers, if there is a lack please add in the comment section)
1, Freescale+NXP: The Netherlands, mainly provides 16-bit and 32-bit MCU. Applications: Automotive electronics, LED and general lighting, healthcare, multimedia convergence, Appliances and power tools, building automation technology motor control, power and power converters, energy and smart grid, automation, computer, and communication infrastructure.
2, Microchip+Atmel: The United States, mainly provides 16-bit, and 32-bit MCU. Application: Automotive electronics, industrial, motor control, automotive, building automation, home appliances, home entertainment, industrial automation, lighting, Internet of things, intelligent energy, mobile electronic equipment, computer peripherals.
3, Cypress+Spansion: The United States, mainly provides 8-bit, 16-bit, and 32-bit MCU. Applications: Automotive electronics, home appliances, medical, consumer electronics, communications, telecommunications, industrial, wireless.
4, ADI: The United States, mainly provides 8-bit, 16-bit, and 32-bit MCU. Applications: Aerospace and defense, automotive applications, building technology, communications, consumer electronics, energy, healthcare, Instrumentation and measurement, electrical machinery, industrial automation, and security.
5, Infineon: Germany, mainly provides 16-bit and 32-bit MCU. Scope of application: automotive electronics, consumer electronics, engineering, commercial and agricultural vehicles, data processing, electric transportation, industrial application, medical equipment, mobile devices, motor control and drive, power supply, for motorcycles, electric bicycles, and small electric vehicles, smart grid, lighting, solar wind power system solutions, system solutions.
6, ST Microelectronics: Italy/France, mainly provides 32-bit MCU. Applications: LED and general lighting, transportation, healthcare, multimedia convergence, Appliances, and power tools, building automation technology motor control, power, and power converters, energy and smart grid, automation, computer, and communication infrastructure.
7, Qualcomm: Us, mainly provides 16-bit and 32-bit MCU. Applications: Smartphones, tablets, wireless modems.
8, Texas Instruments: 16-bit, 32-bit MCU. Applications: Automotive electronics, consumer electronics, medical devices, mobile devices, communications.
9, Maxim: The United States, mainly provides 32-bit MCU. Application: automotive electronics, consumer electronics, industrial applications, security.
In Japan and South Korea
1, Renesas: Japan, mainly provides 16-bit and 32-bit MCU. Applications: Computer and peripherals, consumer electronics, health, and medical electronics, automotive electronics, industry, and communications.
2, Toshiba: Japan, mainly provides 16-bit and 32-bit MCU. Application: Automotive electronics, industrial, motor control, wireless communications, mobile phones, computers, peripheral equipment, video and audio, and video, the consumer (home appliances), LED lighting, security, power management, entertainment equipment.
3, Fujitsu: Japan, mainly provides 32-bit MCU. Applications: automotive, medical, machinery, home appliances.
4, Samsung Electronics: South Korea, mainly provides 16-bit and 32-bit MCU. Application: Automotive electronics, industrial, motor control, automotive, building automation, home appliances, home entertainment, industrial automation, lighting, Internet of things, intelligent energy, mobile electronic equipment, computer peripherals.
In China Mainland
1, Sigma microelectronics: mainly provides 32-bit MCU, application range: telecommunications, manufacturing, energy, transportation, power, etc.
2, Zhuhai Obit: mainly provides 32-bit MCU, application range: aerospace: satellite and arrow station ship, aircraft; High-end industrial control: embedded computer; Ship control, industrial control, power equipment, environmental monitoring.
3, Zhaoyi innovation: mainly provide 32-bit MCU, application scope: industrial automation, human-machine interface, motor control, security monitoring, smart home, Internet of things.
4, Sheng Si Microelectronics: mainly provides 8-bit, 32-bit MCU, application scope: small household appliances, consumer electronics, remote control, mouse, lithium battery, digital products, automotive electronics, medical instruments, and measurement, toys, industrial control, smart home and security, and other fields.
5, Xinhai Technology: mainly provides 16, 32-bit MCU, application scope: instrumentation, Internet of things, consumer electronics, home appliances, automotive electronics.
6, Lianhua INTEGRATED circuit: mainly provides 8-bit, 16-bit MCU, application range: consumer electronics, white goods, industrial control, communication equipment, automotive electronics, computers.
7, Zhuhai Jianrong: mainly provides 8-bit MCU, application range: household appliances, mobile power supply.
8, Actions Technology: mainly provides 8-bit to 32-bit MCU, application range: tablet PC, smart home, multimedia, Bluetooth, wi-fi audio.
9, Aske Microelectronics: mainly provides 8-bit, 16-bit MCU, application scope: consumer chips, communication chips, information chips, home appliances.
10, Huaxin Microelectronics: mainly provide 8-bit, 4-bit MCU, application range: satellite receiver, mobile phone charger, calendar, multi-in-one remote control.
11, Shanghai Beiling (Huada Semiconductor Holdings): mainly provides 8-bit, 16-bit, 32-bit MCU, application scope: computer peripheral, HDTV, power management, small household appliances, and digital household appliances.
12, Haier integrated circuit: mainly provides 14-bit, 15-bit, 16-bit MCU, application range: consumer electronics, automotive electronics, industry, intelligent instrument.
13, Beijing Junzheng: mainly provides 32-bit MCU, application scope: wearable devices, Internet of Things, smart home appliances, automobiles, consumer electronics, tablet computers.
14, Micro semiconductor: mainly provides 8-bit MCU, application scope: intelligent home appliances, automotive electronics, security monitoring, LED lighting and landscape, intelligent toys, smart home, consumer electronics.
15, Suzhou Loongson INTEGRATED circuit: mainly provides 32-bit MCU, application scope: power monitoring, smart grid, industrial digital control, Internet of things, smart home, data monitoring.
16, Purple light microelectronics: mainly provide 8-bit, 16-bit MCU, application range: intelligent home appliances.
17, Times Mincore: mainly provides 32-bit MCU, application scope: automobile navigation, traffic monitoring, fishing boat supervision, power, and telecommunication network.
18, China Resources Silicon Microelectronics (a subsidiary of China Resources Micro): mainly provides 8-bit, 16-bit MCU, application range: consumer electronics, industrial control, home appliances.
19, Guoxin Technology: mainly provides 32-bit MCU, application scope: information security, office automation, communication network, information security.
20, Zhongtian Micro: mainly provides 32-bit MCU, application scope: smartphone, digital TV, set-top box, automotive electronics, GPS, e-reader, printer.
21, China Resources Microelectronics: mainly provide 8-bit, 16-bit MCU, application range: household appliances, consumer electronics, industrial automation control of general control circuit.
22, Zhongying Electronics: mainly provide 4-bit, 8-bit, 16-bit, 32-bit MCU, application range: home appliances, motor.
23, Smart microelectronics: mainly provides 32 bits, application scope: motor control, Bluetooth control, HD display, wireless charging, UAV, micro printer, smart label, e-cigarette, LED dot matrix screen, etc.
24, New Tang Technology: mainly provides 8-bit MCU, application scope: lighting, Internet of things, etc.
25, Neusoft Carrier: mainly provides 8-bit, 32-bit MCU, application range: household appliances, smart home, instrumentation, LCD panel controller, industrial control, etc.
26, Bentley: mainly provides 32-bit MCU, application scope: smart home, industrial control, and consumer products.
27, Shengquan Technology: mainly provides 8-bit MCU, application scope: vehicle, education, industrial control, medical, and other small and medium-sized display panel.
28, Hangshun chip: mainly provides 8-bit, 32-bit MCU, application range: automobile, Internet of things, etc.
29, Fudan Microelectronics: mainly provide 16-bit, 32-bit MCU, application scope: intelligent electricity meter, intelligent door lock, etc.
30, Huada Semiconductor: mainly provides 8-bit, 16-bit, 32-bit MCU, application scope: industrial control, intelligent manufacturing, intelligent life, and Internet of things, etc.
In Taiwan Region of China
1, Macrocrystal Technology: mainly provides 32-bit MCU. Applications: communication, industrial control, information appliances, voice.
2, Shengqun Semiconductor: mainly provide 8-bit, and 32-bit MCU. Application: Consumer electronics, LED lighting, etc.
3, Sunsun Technology: mainly provide 8-bit, and 16-bit MCU. Application: Home audio and video.
4, Zhongying Electronics: mainly provides 4-bit and 8-bit MCU. Application: Charger, mobile power supply, household appliances, industrial control.
5, Songhan Technology: mainly provide 8-bit, and 32-bit MCU. Application: remote controller, intelligent charger, size system, electronic scale, ear temperature gun, sphygmomanometer, tire pressure meter, all kinds of measuring, and health equipment.
6, Warband Electronics: mainly provides 8-bit and 16-bit MCU. Applications: Automotive electronics, industrial electronics, networks, computers, consumer electronics, Internet of things.
7, ten-speed technology: mainly provides 4-bit, 8-bit, and 51-bit MCU. Application: remote control, small household appliances.
8, U-wah Microelectronics: mainly provides 4-bit and 8-bit MCU. Application: Sound recording integrated circuit products, consumer electronics, and household products.
9, Yingguang Technology MICROcontroller: mainly provides 4-bit and 8-bit MCU. Applications: machinery, automation, household appliances, robots.
10, Yilong Electronics: mainly provide 8-bit, and 16-bit MCU. Application: Consumer electronics, computers, smartphones.
▮ MCU learning tips
The basic principles and functions of any MCU are almost the same with minor differences except the configuration and number of peripheral function modules, instruction system, etc.
For instruction systems, although the forms appear to be different, in fact only the symbols are different, the meaning they represent, the function to be accomplished and the addressing mode are basically similar.
To understand an MCU, the first thing we need to know is its ROM space, RAM space, the number of IO ports, the number of timers and timing mode, the Peripheral Circuit provided, interrupt source, working voltage, power consumption, etc.
After understanding these MCU Features, the next first step is to compare the functions of the selected MCU with those required by the actual project development, so as to determine which resources are currently needed and which are not used in this project.
For the functions needed in the project but not provided by the selected MCU, it is necessary to carefully understand the relevant information of MCU in order to realize them in an indirect way. For example, if the developed project needs to communicate with the PC COM port, and if the selected MCU does not provide a UART port, then an external interrupt can be considered to realize them.
For resources needed for project development, you need to carefully understand and read their Manua*, and for functional modules that are not needed, you can ignore or browse. For MCU learning, the application is the key and the primary purpose.
Now that you know what the MCU does, you can start programming.
For beginners or designers who use this MCU for the first time, they may encounter many unclear functions of MCU. For this kind of problem, there are two ways to solve it. One is to write special verification programs to understand the functions described in the data. The other can be temporarily ignored, SCM programming in accordance with their current understanding to write, left to debug to modify and improve. The former method is suitable for time more loose projects and beginners, and the latter method is suitable for people with certain SCM development experience or project progress is more urgent.
The instruction system must not take much time to understand. The instruction system is only a symbol of logical description, only in the programming according to their own logic and the logical requirements of the program to view the relevant instructions, and with the programming, the instruction system will become more and more skilled, and even can not consciously memorize.
▮ Engineers on MCU programming summary
1, To develop the good habit of summary, the summary is not only a summary of their own learning, but also a review and deepening of the learning process, but also to avoid the second mistake.
2, Before writing the program, we should have a familiar understanding of the project, so that we have a good idea and a general framework. It is important to think carefully about the layout and what makes the most sense. To analyze which module to do first, specific steps to the module, how to name each function, and the connection with other modules. Take a piece of paper and jot down significant progress.
3, For the modular programming of C language, we should first divide each module, a module programming, and determine a sequence, according to the sequence, after the success of the module to write the next one. For header files, write the module’s header file after the module is written.
4, Warning do not ignore, that the program must be unreasonable, to understand its source, and find a solution. Should have pertinence when looking for a source, can search the data of this respect on the Internet, or consult to others. For example, the main function of another project was added to this project. There are even functions named repeatedly. Also according to the experimental phenomenon analysis of the cause, step by step. And the wrong interface was chosen when defining the port. Sometimes, it’s good to have a rest when you can’t solve it. No matter how simple things are, they can go wrong.
In the MCU application development, the use of code efficiency, single-chip anti-interference, and reliability problems are still troubled. Several basic skills that should be mastered in the development of MCU are summarized.
▮ MCU development skills
1, how to reduce the bugs in the program
For how to reduce program bugs, you should consider the following out-of-range management parameters that should be considered in system operation.
Physical parameters: these parameters are mainly the input parameters of the system, including excitation parameters, running parameters in acquisition processing, and the result parameters at the end of processing.
Resource parameters: These parameters are mainly the resources of circuits, components, and functional units in the system, such as memory capacity, storage unit length, and stack depth.
Application parameters: these application parameters are often expressed as the application conditions of some microcontrollers and functional units. Process parameters: parameters that change in order during system operation.
2, How to improve the efficiency of C programming code
It is an inevitable trend for the development and application of single-chip microcomputers to use the C language for programming. For maximum efficiency when programming in C, it is best to familiarize yourself with the C compiler you are using. First, test each C language compiled after the corresponding assembly language statement line number, so you can clearly know the efficiency. Use the most efficient statements for future programming. Different C compilers have some differences, so compilation efficiency can also be different. A good EMBEDDED SYSTEM C compiler code length and execution time is only 5-20% longer than the same level of functionality written in assembly language.
For complex projects with tight development time, C can be used, but the premise is that you are familiar with the C language and C compiler of the MCU system, paying special attention to the data types and algorithms supported by the C compiler system. Although C language is the most common high-level language, different MCU manufacturers have different C language compilation systems, especially in the operation of some special functional modules. So if you don’t understand these features, debugging can be very problematic and can lead to less efficient execution than assembly language.
3, How to solve the problem of anti-interference of MCU
The most effective way to prevent interference is to remove interference sources and cut off interference paths, but it is often difficult to do so, so we can only look at whether the anti-interference ability of SCM is not strong enough. While improving the anti-interference ability of hardware systems, software anti-interference has been paid more and more attention to for its flexible design, saving hardware resources, and good reliability.
The single-chip microcomputer interference is the most common phenomenon is reset, as for the program run fly, in fact, can also use software trap and watchdog to pull the program back to reset state, so the single-chip microcomputer software anti-interference is the most important to deal with the reset state.
Generally, MCU will have some sign registers, that can be used to judge the reset reason; Alternatively, you can bury some tokens in RAM yourself. In each program reset, different reset causes can be determined by judging these signs. You can also jump directly to the corresponding program according to different flags. In this way, the program will run continuously and the user will not be aware that the program has been reset.
4, how to test the reliability of the single-chip system
When a single-chip system design is completed, there will be different testing items and methods for different single-chip system products, but there are some that must be tested:
Test the perfection of MCU software function
Power-on and power-off tests
ESD and EFT and other tests
Sometimes, we can also simulate the damage that might occur if we use it artificially. For example, the human body or clothing fabric deliberately friction microcontroller system contact port, thus testing antistatic ability. The high-power electric drill is used to work near the single-chip microcomputer system, so as to test the ability of anti-electromagnetic interference.
▮ Words in the end
To sum up, SCM has become an important aspect of computer development and application, the significance of SCM application also lies in that it fundamentally changes the traditional control system design ideas and design methods.
Most of the functions that had to be realized by analog or digital circuits in the past can now be recognized by software using a single-chip microcomputer. This kind of software instead of hardware control technology also called micro control technology, is a revolution of traditional control technology.
In addition, in the process of development and application, we should master skills and improve efficiency, so that it can be used more widely.
Copyright notice: This article source network, is free to convey knowledge, copyright belongs to the original author. If the copyright of the work is involved, please contact me for deletion.