How to design software for electronic product development
The software design in the development of electronic product scheme includes making the overall program, drawing the program flow chart, compiling the program, and checking, debugging and modifying the program.
1. Formulate the overall program
The overall program refers to the program structure, data form and program implementation methods and means from the perspective of program. When making the overall design scheme, the actual SCM application scheme has complex functions, large amount of information and long program, which requires the designer to choose a practical programming method.
At present, there are many kinds of programming methods, which are widely used in single chip microcomputer
The commonly used programming methods include modular programming method, subroutine programming method, top-down progressive refinement programming method, structured programming method, etc.
The central idea of modular programming method is to divide a multi-functional and complex application program into several relatively independent program modules according to functions. Each module can be designed, programmed and debugged separately, and then assembled for joint debugging to become a complete application program.
The method of subroutine programming is to program, debug and check the error of a relatively independent sub module in the form of subroutine, and then call the subroutine to form a complete application program. This kind of program design idea is clear, easy to debug, check error, modify, and flexible organization. It is a popular program design method at present.
The top-down progressive refinement of the program design method, requires first from the main program at the scheme level, focus on solving global problems, and then layer by layer refinement, and gradually refine to complete the design of an application program. This program design method is widely used in general single chip microcomputer application program.
Structured programming is an ideal programming method. It requires appropriate restrictions on the program in the programming process, especially the use of transfer and branch instructions, so as to control the complexity of the program and make the context of the program consistent with the execution process.
2. Draw program flow chart
No matter what kind of programming method is adopted, the overall block diagram of the program should be drawn according to the general task of the application scheme and the functional requirements of the control object, so as to describe the overall structure of the program. On the basis of the overall program block diagram, the designer also needs to refine the program flow chart with specific algorithm (or mathematical model).
3. Programming
After drawing the program flow chart, the structure and thinking of the whole program are very clear. At this time, we can consider and arrange some overall problems. For example, address space allocation, working register arrangement, data structure, port address and input / output format, etc.
When programming, we should pay attention to the reasonable choice of instructions, especially the important parts, and the program segments involving algorithms should be carefully written. Software reliability measures must be paid attention to, such as instruction redundancy, software traps, etc., which can improve the anti-interference ability of software and prevent software crash or program running away. As long as the programmer is familiar with the internal structure, function and command scheme of the selected single chip microcomputer, and master the programming methods and skills, it will not be very difficult to compile high-quality application software according to the program flow chart.
4. Check, debug and modify the program
After a practical application program is compiled, there are many potential risks and errors. If these hidden dangers and errors are not eliminated and modified, once the errors appear in the operation, it is possible to make the program into an uncontrollable situation. Therefore, it is necessary to check the static state before on-line debugging after programming. The static inspection of the prepared program often speeds up the debugging process of the whole program. The static inspection is carried out from top to bottom according to the program flow chart. If any error is found, it should be corrected in time.