What is Embedded C programming and how is it different?

Last updated on May 07,2020 29.9K Views

What is Embedded C programming and how is it different?


C is a high-level programming language intended for system programmingEmbedded C is an extension that provides support for developing efficient programs for embedded devices. Yet, it is not a part of the C language. In this “Embedded C programming” article, we shall discuss the following topics.

What is Embedded C Programming

Embedded C programming language is an extension to the traditional C programming language, that is used in embedded systems. The embedded C programming language uses the same syntax and semantics as the C programming language.

The only extension in the Embedded C language from normal C Programming Language is the  I/O Hardware Addressing, fixed-point arithmetic operations, accessing address spaces, etc.

Now will move on to the Difference between C and Embedded C.

Difference between C and Embedded C:


C Programming LanguageEmbedded C Programming Language
In nature, it is a native developmentIn nature, It is cross-development
It is independent of hardware architectureIt is hardware dependent
Used for desktop applicationUsed for limited resources like RAM and ROM

Now let’s learn about the basic structure of Embedded C program.

Basic Structure of Embedded C Program:

The embedded C program has a structure similar to C programming.

The five layers are:

  2. Pre-processor directives
  3. Global declaration
  4. Local declaration
  5. Main function()

The whole code follows this outline. Each code has a similar outline. Now let us learn about each of this layer in detail.

Multiline Comments . . . . . Denoted using /*……*/
Single Line Comments . . . . . Denoted using //
Preprocessor Directives . . . . . #include<&hellip;> or #define
Global Variables . . . . . Accessible anywhere in the program
Function Declarations . . . . . Declaring Function
Main Function . . . . . Main Function, execution begins here
      Local Variables . . . . . Variables confined to main function
      Function Calls . . . . . Calling other Functions
      Infinite Loop . . . . . Like while(1) or for(;;)
      Statements . . . . .
Function Definitions . . . . . Defining the Functions
      Local Variables . . . . . Local Variables confined to this Function 
      Statements . . . . .

Let’s look into the Comment section.

Comment Section:

Comments are simple readable text, written in code to make it more understandable to the reader. Usually comments are written in // or /* */.

Example: //Test program

Let’s look into Preprocessor Directives Section.

Preprocessor Directives Section:

The Pre-Processor directives tell the compiler which files to look in to find the symbols that are not present in the program.

For Example, in 8051 Keil compiler we use,


Let’s look into Global declaration Section.

Global Declaration Section:

This part of the code is the part where the global variables are declared. Also, the user-defined functions are declared in this part of the code. They can be accessed from anywhere.

void delay (int);

Let’s look into Local declaration section.


Local Declaration Section:

These variables are declared in the respective functions and cannot be used outside the main function.

Let’s look into the Main function section.


Main Function Section:

Every C programs need to have the main function. So does an embedded C program. Each main function contains 2 parts. A declaration part and an Execution part. The declaration part is the part where all the variables are declared. The execution part begins with the curly brackets and ends with the curly close bracket. Both the declaration and execution part are inside the curly braces.

void main(void) // Main Function
     P1 = 0x00;
           P1 = 0xFF; 
           P1 = 0x00; 


Function Definition Section

In this section, the function is defined.

This is the basic structure of the embedded c program.

With this, we come to an end of this “Embedded C Programming” article. I hope you have understood the basic structure.

Now that you have understood the basics of Programming in C, check out the training provided by Edureka on many technologies like Java, Spring and  many more, a trusted online learning company with a network of more than 250,000 satisfied learners spread across the globe

Got a question for us? Mention it in the comments section of this blog and we will get back to you as soon as possible.