Embedded C Programming – RoboMart.com – Independence Day Sale


Today is August 14, 2015 that is 1 day left to celebrate Independence Day. We are happy to announce we are offering Discounts on all our RoboMart Products check out now. Offer will be ended soon..

Every C language program must have at least one function, namely main(). The function main() is the foundation of a C language program, and it is the starting point when the program code is executed. All functions are invoked by main() either directly or indirectly. Although functions can be complete and self-contained, variables and parameters can be used to cement these functions together.

The function main() is considered to be the lowest-level task, since it is the first function called from the system starting of the program. In many cases, main() will contain only a few statements that do nothing more than initialize and steer the operation of the program from one function to another.

You can easily learn by making practical experiments. Here we designed AVR Development for starters.

Buy AVR Development Board from our store Buy Now

Example Embedded C Program:

The program shown above will compile and operate perfectly, but you will not know that for sure, because there is no indication of activity of any sort.Review its functionality, and begin to study the syntactical elements of the language:

This program will print the words “HELLO WORLD” to the standard output, which is most likely a serial port. The microcontroller will wait, forever or until the microcontroller is reset. This demonstrates one of the major differences between a personal computer
program and a program that is designed for an embedded microcontroller: namely,that the embedded microcontroller applications contain an infinite loop. Hence, every embedded microcontroller application has an infinite loop built into it somewhere, such as the while(1) in the example above. This prevents the program from running out of things to do and doing random things that may be undesirable.

The example program also provides an instance of the first of the common preprocessor compiler directives. #include tells the compiler to include a file called stdio.h as a part of this program. The function printf() is provided for in an external library, and it is made available to us because its definition is located in the stdio.h file. As we continue, these concepts will come together quickly.


These are some of the elements to take note of in the previous examples:
A semicolon is used to indicate the end of an expression.
Braces {} are used to delineate the beginning and the end of the function’s contents. Braces are also used to indicate when a series of statements is to be treated as a single block.
“text” Double quotes are used to mark the beginning and the end of a text string.
Slash-slash or slash-star/star-slash // or /* . . . */ are used as comment delimiters.

Comments are just that, a programmer’s notes.  The comments shown in this text are used to explain the function of each line of the code in the example.The comments should always explain the actual function of the line in the program, and not the specific instructions that are used on the line.
The traditional comment delimiters are the slash-star (/*), star-slash (*/) configuration. Slash star is used to create block comments. Once a slash-star (/*) is encountered, the compiler  will ignore the subsequent text, even if it encompasses multiple lines, until a star-slash (*/) is Unexcepted. Refer to the first line of the main() function in the previous program example for an example of these delimiters.
The slash-slash (//) delimiter, on the other hand, will cause the compiler to ignore the comment text only until the end of the line is reached. These are used by main() function of the example program.

Elements Example:

In this Code I will Show you the Comment Expressions

We hope you enjoyed the tutorial. Check regularly for more interesting tutorials.


Thank you..

RoboMart Team