Lec05C - Lecture 5 C for Embedded Systems Outline...

Info iconThis preview shows pages 1–12. Sign up to view the full content.

View Full Document Right Arrow Icon
ECE 471 5-C-1 Outline C-language review Bit manipulation Masking Monitoring I/O bits and hand shaking Shift operators Bit fields Port addressing definition and access Discussion and Summary Lecture 5 C for Embedded Lecture 5 C for Embedded Systems Systems
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 5-C-2 C Language Review Review C language Fundamentals (statements, loops, conditional statements, and program structures) Bit operations, Bit fields Define variables in registers, RAM and ROM. Pointers Union type Pointer to functions, callback functions Access specified memory addresses Conditional compilation Header file Macros
Background image of page 2
ECE 471 5-C-3 C language Fundamentals Basic components of a C program Main program Comments Basic variable types Variables definitions Assignments Arithmetic operations Logic operations Loops Function calls
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 5-C-4 Main Program #include <stdio.h> void main ( void) { printf(“This is my main program\n”); }
Background image of page 4
ECE 471 5-C-5 Comments Any character string between /* and */ Basic variable types There are four basic variable types char int float 32bit double Variables definitions Examples: char name; /*name is a variable*/ int loop_counter, index; float temperature, pound, kilogram; double weight ;
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 5-C-6 Assignments name =‘A’; temperature = 39.5; weight = 200; Arithmetic operations -- +, -, *, /, % kilomgram = 2.2 * pound; pound = kilogram / 2.2; 12%10=2 Logic Operations -- &&, || { name =‘A’; }
Background image of page 6
ECE 471 5-C-7 Loops for loop for (x =0; x < 100; x++) { printf(“x=%d\n”,x) } while loop do loop x = 0; x=0; while(x < 100) do { { printf(“x=%d\n”,x); printf(“x= %d\n”,x); x++; x++; } } while( x<100);
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 5-C-8 Function Calls – with return value #include <stdio.h> float kg2lb (float kilo); float kg2lb (float kilo) { float temp; temp = kilo * 2.2; return temp; } void main(void) { float kilogram, pound; kilogram = 5.6; pound = kg2lb(kilogram) printf(“%f kilogram = %f pound\n”,kilogram,pound); }
Background image of page 8
ECE 471 5-C-9 Function Calls – passing out parameters #include <stdio.h> void kg2lb (float kilo, float *lb); /*this is the function prototype*/ void kg2lb (float kilo, float *lb) { *lb = kilo * 2.2; } void main(void) { float kilogram, pound; kilogram = 5.6; printf(“%f kilogram = %f pound\n”,kilogram,pound); }
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
ECE 471 5-C-10 Word Sizes The size of a word is usually dependent on the register size of the processor 8-bit processors generally have a word size of 16 bits Intel 16 bit 8088/8086 family has a word size of 16 bits Intel 32 bit 80x86 family and Motorola 68000 family have word sizes of 32 bits The word size corresponds to the default size of an integer variable.
Background image of page 10
ECE 471 5-C-11 Data Types Four basic types char - character integer - integer float - single precision floating point number double - double precision floating point number Type qualifiers for integer type
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 51

Lec05C - Lecture 5 C for Embedded Systems Outline...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online