Embedded System C language programming how to learn?

Source: Internet
Author: User

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

C language is broad and profound, played for a long time, has been wandering in the entrance. Read a lot of other people's programming experience, plus the project program to do more and more, until this half a year to suddenly have a lot of experience, tomorrow will go home, afternoon free to try to sum up some experience, like to learn from the teachers and siblings help.

First of all to talk about several important principles of programming, read a lot of other people's programming experience, more to say skills. Skills can significantly improve the efficiency of the program, is important but the mastery of skills or a large number of engineering practice, only after a certain degree of knowledge can pursue these programming skills. But the principle of programming is to be in the beginning of learning to conscientiously implement, to develop good programming habits, hard skills after practicing the upper level will not go mad.

Anyway, what are the principles for embedded system C programming? With the development of the Times and technology, the problem may be different, but summed up there is a lot of consensus. According to the current practice of software engineering, and the practice of our department, enumerate the most important principles:

Module Division. C language, as a structured programming language, is mainly based on function in the Division of modules:

(1) A function module is the combination of a. c file and a. h file, and the. h file is a declaration of the module functional function and the variable

(2) External functions and data provided by the module to other modules are required to be declared in the extern keyword in the. h file

(3) Functions and global variables within a module can only be defined in the. c file

(4) It is not allowed to define a variable in the. h file (the difference between defining and declaring a variable is to define an action that produces a memory allocation, whereas a declaration simply tells the module containing the declaration to look for external functions and variables from other modules during the connection phase).

Second embedded system program consists of two types of modules written in three layers:

(1) Hardware driver module, a specific hardware corresponding to a module, including the integrated hardware modules and external expansion of the

(2) The SOFTWARE function module, the SOFTWARE function module is the hardware independent logic function which is built on the hardware drive module.

(3) Three-layer writing is HAL (Hardware application layer), API (Application function Package), APP (logic application layer) Note: The name is borrowed, the table big meaning just. HAL is the hardware driver module and system hardware is closely related, the API can be built on the HAL Hardware Application service program can also be a general function module, app is the final form of embedded system application of functional logic. Hal and APIs are designed to facilitate technology build-up and improve development efficiency, and apps are tailored for special applications.

Iii. requirements for interruption of service procedures:

(1) cannot return a value

(2) cannot pass parameters to ISR

(3) The ISR should be as dapper as possible and not allow for the operation of waiting signals.

Iv. Programming Style issues

The basic technique of C language needing to learn to use skillfully

(1) Data pointers, you can't just use arrays

(2) macro definition, define register address, define macro function, etc.

(3) Application of function pointers

(4) Conditional compilation, with the application of the operating system is often used

Don't be lazy, write the necessary notes.

Seven, do the above points can absorb superb programming skills.

Reprint please keep the connection http://www.52jiadian.com/189.html

This paper is organized by www.uchn.org

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.