Hardware engineers need to know 8 software design skills

     嵌入式系统设计不仅要了解硬件还应该了解它与软件之间的相互影响和作用。硬件设计需要一定的设计范例,这点对于软件设计却不那么适用。如何从单纯的硬件设计过渡到硬软结合的设计,在你着手开发软件时需注意以下八个软件设计技巧。

  
1. Design of a control flowchart

        You can not help but start to write code when engineers to develop software this step. This mindset just before the schematic has not been completed to start trying to draw PCB. When started to develop software, to restrain the impulse to write the code, it should be replaced by structural design software flow chart, it is very important. It can be clearly presented to a flowchart of components required for each software developer, as a circuit diagram listing various hardware components designed as desired. Can do to make the program as a whole is largely better organized, but would also reduce long development cycles accounted for debugging effort thus saving time reducing the tedious debugging.

2. A state machine control program

        Process state machine is one of the best software inventions of the 20th century. Application is generally divided into a plurality of different states, each state controlling a specific program branches. The state machine includes internal states and transitions according to a state controlled by different excitation. The mechanism using a state machine design software enables modular maintainable software development easier and easier to understand. Example state machine theory and algorithms everywhere.

3. Avoid using global variables

        In the last functional programming, programmers write programs using functions, their only goal is to make the program run as fast as possible without regard to the structure and reuse program. Such procedures styles when using global variables scope variables inadvertently cause other functions to modify risk. Such variables are occupied and rewritten many times. Today, object-oriented programming, member variables are defined within a minimum range of action and to avoid re-encapsulated complex value and abuse. It is proposed to minimize the use of global variables, it is necessary, using the C language keyword "extern" to describe.

4. take full advantage of the modular design concept

        If you ask an engineer part of the project which are most likely to delay delivery and beyond the forecast period, the answer must be that the software cycle. Software is often complex and difficult to develop and maintain, especially when the project application in one single file, or a few loose structure of the file. For ease of code reuse and software maintenance and reduce the complexity of the software is strongly recommended level programming languages ​​play modular nature, the utility function separated out as a separate module in the program structure. Let programmers start creating in this way contains common functions and common declaration defines, it can easily be reused by other code, which not only saves time costs at a later stage of testing can improve the quality of the code.

 5. Interrupt Service Event

        Interrupt service event is kept concise processor interrupt program is being executed in favor of a mechanism to request the interruption of peripheral processing trigger. The processor interrupt request requires a lot of overhead, specifically in the state save the interrupted program (the segment address of the next instruction onto the stack, the offset address and the program status register, and sometimes several stack register values) is performed interrupt service routine and then continue with the recovery in the breakpoint (turn the stack registers), although it's very fast processor overhead but this still needs to be considered. In general, in order to avoid conflict with the main programmers always want to interrupt the execution time is reduced to a minimum. This means that the interrupt service event should be short and simple. You can not call a function in the interrupt routine. In addition, if you need to handle interrupt events is particularly complex or takes a long time, this time the interrupt service routine should meet the minimum requirements, for example, load data into the buffer, the flag is set, and let the main program to deal with reading The data. Most of the work cycle such processors are not an interrupt processing program.

 Using a processor 6. Sample Code

        Test equipment for hardware design, prior to the drawing board standard test circuit help engineers understand the characteristics of the circuit. The same can be applied to software design, semiconductor manufacturers usually the function of each part of the test sample program the microprocessor to provide engineers experience how each part works. Accordingly organizational structure of the software can predict in advance and problems in the design. Determine in advance the potential obstacles in the design of products than in the first few hours of the completion identify problems more scientific and reasonable. It is worth noting that the code is not usually supplied by the manufacturer of modular and do the necessary changes is difficult to directly used for the actual software.

The control function of the complexity of

        There is a saying called "KISS" in engineering design, which means "Keep It Simple Silly". In dealing with some of the most complex tasks simple and effective way is to break it down into several simple sub-tasks, when the task or function is very complex, it is difficult to pay attention to all the details it is difficult not go wrong. When engineers to write a complex function can be understood at the time, you may need to maintain the program after a period of time can not be clearly showing the original design idea that is worth considering. There are a lot of techniques to measure the complexity of functions such as "cycle complexity." Experience tells us that the complexity of the cycle function should be below 10 better.

8. Detailed documentation

        In the fierce competition in the software development focus easily confined to writing and debugging code and ignore the written document. Sometimes under pressure required to write documentation, developer documentation usually arranged in the last part of a project focused on the development of writing. However, writing documentation to the code should take in mind there is still relatively clear when comparing the key, so that the subsequent development or read the comments of their own time can be quickly recalled the design.

Guess you like

Origin blog.51cto.com/14355585/2407421