In the development of microcontroller applications, engineers are still troubled by issues such as code usage efficiency, microcontroller anti-interference and reliability. In order to help engineers solve the problems in microcontroller design, several basic skills that should be mastered in microcontroller development are summarized.
1. How to improve the efficiency of C language programming code.
Using C language to program microcontrollers is an inevitable trend in the development and application of microcontrollers. If you want to achieve maximum efficiency when programming in C, it is best to be familiar with the C compiler you are using. First test the number of lines of assembly language statements corresponding to each C language compiler, so that you can clearly know the efficiency. When programming in the future, use the statement with the highest compilation efficiency.
Each C compiler will have certain differences, so the compilation efficiency will also be different. The code length and execution time of an excellent C compiler for embedded systems are only 5-20% longer than the same function written in assembly language.
For complex projects with tight development time, C language can be used, but the prerequisite is that you are very familiar with the C language and C compiler of the MCU system. Pay special attention to the data types and algorithms supported by the C compilation 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 function modules. Therefore, if you do not understand these features, there will be many problems during debugging, which will lead to lower execution efficiency than assembly language.
2. How to reduce bugs in the program?
Some suggestions were given on how to reduce program bugs, pointing out that the over-range management parameters that should be considered during system operation are:
1. physical parameters. These parameters are mainly the input parameters of the system, which include excitation parameters, operating parameters during acquisition processing and result parameters at the end of processing. Set these boundaries reasonably, and treat parameters beyond the boundaries as abnormal incentives or abnormal responses for error handling.
2. Resource parameters. These parameters are mainly the resources of circuits, devices, and functional units in the system, such as memory capacity, storage unit length, and stacking depth. In programming, resource parameters are not allowed to be used out of scope.
3. Application parameters. These application parameters are often represented by the application conditions of some microcontrollers and functional units. Such as E2PROM erasure and write times and data storage time and other application parameter limits.
4. process parameters. Refers to the parameters that change in an orderly manner during system operation.
3. How to solve the anti-interference problem of the microcontroller.
The most effective way to prevent interference is to remove the interference source and block the interference path, but it is often difficult to do so, so we can only see whether the anti-interference ability of the microcontroller is strong enough. The most common phenomenon of microcontroller interference is reset; as for program runaway, software traps and watchdogs can actually be used to bring the program back to the reset state; therefore, the most important thing for microcontroller software to resist interference is to handle the reset state.
Generally, microcontrollers will have some flag registers that can be used to determine the cause of reset; in addition, you can also bury some flags in RAM yourself. Each time the program is reset, different reset causes can be determined by judging these flags; you can also jump directly to the corresponding program based on different flags. This allows the program to run continuously, and the user will not notice that the program has been reset when using it.
4. How to test the reliability of a single-chip microcomputer system.
Some readers want to know what methods are used to test the reliability of the single-chip microcomputer system. "When a single-chip computer system design is completed, there will be different test items and methods for different single-chip computer system products, but there are some It is necessary to test:
1. Test the completeness of the microcontroller software function. This is a test for all microcontroller system functions.
2. The user will inevitably encounter power-on and power-off tests. The power supply can be turned on and off multiple times to test the reliability of the microcontroller system.
If necessary, the reliability of the microcontroller system can be tested under high temperature, high pressure and strong stress conditions. Test in an electromagnetic interference environment.
4. ESD and EFT tests. Various interference simulators can be used to test the reliability of the microcontroller system. For example, use an electrostatic simulator to test the anti-static ESD capability of the microcontroller system; use surge noise simulation. It can also perform fast pulse anti-interference EFT tests and so on.
It can also simulate the damage that may occur during human use, such as deliberately rubbing the contact port of the microcontroller system with a high-power electric drill. Work close to the microcontroller system to test the ability to resist electromagnetic interference.
Previous article:Daniel summarizes several important concepts of microcontrollers
Next article:How to "build a conversation" between different types of microcontrollers? From these examples
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- CGD and Qorvo to jointly revolutionize motor control solutions
- CGD and Qorvo to jointly revolutionize motor control solutions
- Keysight Technologies FieldFox handheld analyzer with VDI spread spectrum module to achieve millimeter wave analysis function
- Infineon's PASCO2V15 XENSIV PAS CO2 5V Sensor Now Available at Mouser for Accurate CO2 Level Measurement
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- Advanced gameplay, Harting takes your PCB board connection to a new level!
- A new chapter in Great Wall Motors R&D: solid-state battery technology leads the future
- Naxin Micro provides full-scenario GaN driver IC solutions
- Interpreting Huawei’s new solid-state battery patent, will it challenge CATL in 2030?
- Are pure electric/plug-in hybrid vehicles going crazy? A Chinese company has launched the world's first -40℃ dischargeable hybrid battery that is not afraid of cold
- How does a “temperature gun” measure your temperature?
- CC2650 launchpad and msp432 launchpad
- Switching Power Supply Interest Group 19th Task
- LED power supply not working
- Smart MM32 + UCOS + uCGUI
- How to decorate a chemical analysis room?
- Find VHDL half-integer division
- Has anyone used AMIS-30543 to drive a stepper motor?
- Is the emitter voltage of the PNP tube pulled down by the base?
- Basic knowledge of wireless WiFi coverage