Embedded C - Lecture 2
Embedded C - Lecture 2
2.1 Introduction: Whenever the conventional „C‟ language and its extensions are used for
programming embedded systems, it is referred as „Embedded C‟ programming.
ii) Data Types: The following table is given for 32 bit platform
For embedded application memory is a big constraint. So optimum data type for a variable is
selected. For example if the variable is expected to be in the range 0 to 255 then „unsigned char‟
or „unsigned short int‟ data types are used instead of „int‟ or „unsigned int‟.
iii) Storage class:
Apart from the above four storage classes, „C‟ supports storage class „global‟. There is no explicit
storage class for „global‟. The way of declaration of a variable determines whether it is global or not.
v) Logical Operations
vi) Relational Operations
User defined functions are programmer created functions for various reasons like
modularity, easy understanding of code, code reusability etc.
xii) Structures and Unions
„structure‟ is a variable holding a collection of data types ( int, float, char, long
etc.).The data types can be either unique or distinct.
Union is a concept derived from structure and union declaration follows the same
syntax.
Union differs from structure in the memory allocation technique for the member
variables. Whenever union variable is created, memory is allocated only to member
variable of union requiring the maximum storage size. But for structure memory is
allocated to each member variables.
Because of the above reason, in embedded C applications , union may be used for
fast accessing of individual bytes of „long‟ or „int‟ variables, eliminating the need
for masking the other bytes of „long‟ or „int‟ variables which are of no interest, for
checking some conditions.