Presentation is loading. Please wait.

Presentation is loading. Please wait.

Presentation By :- Nikhil R. Anande (130950111005) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER.

Similar presentations


Presentation on theme: "Presentation By :- Nikhil R. Anande (130950111005) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER."— Presentation transcript:

1 Presentation By :- Nikhil R. Anande (130950111005) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER AND INTERFACING (2151001)

2

3  we review briefly major aspects of the C programming language. A. Structure of a C program B. Data types and operators C. Flow control in C D. C functions

4  A C program typically has two main sections.  Section #include: to insert header files.  Section main(): code that runs when the program starts.  Section #define: this directive is used for defining a text substitution string.  Comments are text that the compiler ignores.  For a single-line comment, use double forward slashes: For ex: DDRA = 0 00 x ;  Always use comments to make program easy to understand.

5  Comments are text that the compiler ignores.  For a single-line comment, use double forward slashes: For ex: DDRA = 0x00 ;  Always use comments to make program easy to understand.

6 C statements:  C statements control the program flow.  They consist of keywords, expressions and other statements  A statement ends with semicolon. for ex: DDRB = 0xFF;  C blocks:  A C block is a group of statements enclosed by braces {}.  It is typically associated with if, switch, for, do, while, or functions.

7 The main data types in C are  char: 8-bit integer in AVR  int: 16-bit integer in AVR  long int: 32-bit integer in AVR  The above data types can be modified by keyword The above data types can be modified by keyword ‘unsigned’  Char a;  unsigned char b;  unsigned long int c;  In C, a variable or function must be declared before it is used.

8 Arithmetic operators Relational operators Logical operators Logical operators Bit-wise operators

9

10

11 These operators are applied on logical variables or constants.

12 These operators are applied on individual bits of a variable or constant.

13 By default, C statements are executed sequentially. To change the program flow, there are six types of statements if-else statement switch statement Conditional while statement for statement Iterative

14 General syntax if (expression) statement_1; else statement_2;  Example Char a, b, sum; a = 4; b = -5; sm a bu = + b; if (sum < 0) printf(“sum is negative”); else if (sum > 0) printf(“sum is positive”); else printf(“sum is zero”);

15 General syntax: Its format is: switch (expression) case constant_1: statement_1; Break; Case constant_2: statement _ 2; Break; Case constant _ n: statement_n; break; default: statement_other; }

16  General syntax:  While a condition is true, the while loop repeats a statement or block of code.  Before executing the statement the value of expression is checked.  Its is format: while (expression) { statements; }

17 General syntax Its is format: for (expression1; expression2; expression3) { statements; }  expression1 is run before the loop starts.  expression2 is evaluated before each iteration.  expression3 is run after each iteration.

18 C functions are sub-routines that can be called from the main program or other functions. program or other functions. Functions enable modular designs code reuse and hiding of Functions enable modular designs, code reuse, and hiding of complex implementation details. A C function can have a list of parameters and produce a return value.

19


Download ppt "Presentation By :- Nikhil R. Anande (130950111005) Electronic & Communication Engineering. 3 nd Year / 5 th Semester FACULTY GUIDE : RAHIUL PATEL SIR MICROCONTROLLER."

Similar presentations


Ads by Google