This class provides an introduction to the C programming language (as specified by the ANSI C89 standard) in the context of embedded systems. We cover the C language from the ground up from a non-hardware specific point of view in order to focus on the various elements of the C language itself. While not required, previous experience with any programming language or experience with microcontrollers would be helpful. The material is accompanied by a series of hands-on exercises designed to reinforce the fundamentals, all of which are conducted within the MPLAB® X IDE using the 16 bit C compiler and Simulator. Skills learned in this class are applicable to any ANSI C compiler. Hardware and compiler-specific details such as interrupts, memory models and optimization are not discussed. These topics are covered in the compiler-specific classes.
Table of Contents
- C in an Embedded Environment
- Comments
- Variables
- The #include Directive
- Literal Constants
- Symbolic Constants
- The printf() Function
- Operators
- Arithmetic Operators
- Division Operator
- Implicit Type Conversion
- Modulus Operator
- Increment and Decrement Operators
- Assignment Operators
- Relational Operators
- The Difference Between = and ==
- Logical Operators
- Short Circuit Evaluation
- Bitwise Operators
- The Difference Between & and &&
- Shift Operators
- Memory Addressing Operators
- Conditional Operator
- Explicit Type Cast Operator
- Other Operators
- Precedence (Order of Operations)
- Lab Exercise 4: Operators
- Expressions and Statements
- Decision Statements
- Loops
- Functions
- Multi-File Projects and Storage Class Specifiers
- Arrays
- Data Pointers
- Function Pointers
- Structures
- Bit Fields
- Unions
- Enumerations
- Preprocessor Macros with #define
- Resources