Summarize several basic skills that should be mastered in single chip microcomputer development

Publisher:TranquilMind88Latest update time:2020-06-07 Source: elecfans Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

In the development of single-chip microcomputer applications, engineers are still troubled by code efficiency, anti-interference and reliability of single-chip microcomputers. In order to help engineers solve the problems in single-chip microcomputer design, several basic skills that should be mastered in single-chip microcomputer development are summarized based on the discussions in the forum.

1. How to improve the efficiency of C language programming code

Deng Hongjie pointed out that using C language for MCU programming is an inevitable trend in MCU development and application. "If you want to achieve the highest efficiency when programming in C, it is best to be familiar with the C compiler you are using. First test the number of assembly language statements corresponding to each C language compilation, so that you can clearly know the efficiency. When programming in the future, use the statements with the highest compilation efficiency."


He pointed out that each company's C compiler has some differences, so the compilation efficiency will also be different. The code length and execution time of an excellent embedded system C compiler are only 5-20% longer than the same functional level written in assembly language. "For complex projects with tight development time, you can use C language, but the premise is that you are very familiar with the C language and C compiler of the MCU system, and pay special attention to the data types and algorithms that the C compiler system can support.


Although C is the most common high-level language, different MCU manufacturers have different C language compiler systems, especially in the operation of some special function modules. Therefore, if you don’t understand these features, there will be many problems in debugging, which will lead to lower execution efficiency than assembly language. "


2. How to reduce bugs in programs?

Deng Hongjie gave some suggestions on how to reduce program bugs. He pointed out that the out-of-range management parameters that should be considered in system operation are:

1. Physical parameters. These parameters are mainly the input parameters of the system, including excitation parameters, operating parameters in the acquisition process, and result parameters after the process. Reasonable boundaries should be set, and parameters that exceed the boundaries should be treated as abnormal excitation or abnormal response and error handling should be performed.

2. Resource parameters. These parameters are mainly the resources of the circuits, devices, and functional units in the system, such as memory capacity, storage unit length, and stack depth. In programming, resource parameters are not allowed to be used beyond the scope.

3. Application parameters. These application parameters are often expressed as the application conditions of some single-chip microcomputers and functional units, such as the number of erase and write times and data storage time of E2PROM and other application parameter limits.

4. Process parameters: Refers to the parameters that change in an orderly manner during the operation of the system.


3. How to solve the anti-interference problem of MCU

Deng Hongjie pointed out: The most effective way to prevent interference is to remove the interference source and cut off the interference path, but it is often difficult to do so, so we can only see whether the anti-interference ability of the MCU is strong enough. The most common phenomenon of MCU interference is reset; as for the program running away, in fact, the software trap and watchdog can also be used to pull the program back to the reset state; so the most important thing for MCU software anti-interference is to handle the reset state well.


Generally, microcontrollers have some flag registers that can be used to determine the reset reason. In addition, you can also bury some flags in RAM. Every time the program is reset, by judging these flags, you can determine different reset reasons; you can also jump directly to the corresponding program according to different flags. This can make the program run continuously, and the user will not notice that the program has been reset when using it.


4. How to test the reliability of the MCU system

Some readers want to know what methods are used to test the reliability of the MCU system. Deng Hongjie pointed out: "When a MCU system is designed, there will be different test items and methods for different MCU system products, but there are some that must be tested:

1. Test the completeness of the MCU software functions. This is a test of all MCU system functions to test whether the software is written correctly and completely.

2. Power-on and power-off test. During use, users will inevitably encounter power-on and power-off situations. The power supply can be turned on and off multiple times to test the reliability of the microcontroller system.

3. Aging test. Test the reliability of the MCU system under long-term working conditions. If necessary, it can be tested in a high temperature, high voltage and strong electromagnetic interference environment.

4. Tests such as ESD and EFT. Various interference simulators can be used to test the reliability of the microcontroller system.

Reference address:Summarize several basic skills that should be mastered in single chip microcomputer development

Previous article:How to remove the read protection of the STM8S chip that is set to read protection and re-download the program
Next article:Development process of single chip microcomputer application system

Latest Microcontroller Articles
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号