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

Info icon This 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
Image of page 1

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

View Full Document Right 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
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
Image of page 3

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

View Full Document Right Arrow Icon
ECE 471 5-C-4 Main Program #include <stdio.h> void main ( void) { printf(“This is my main program\n”); }
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 ;
Image of page 5

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

View Full Document Right 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 -- &&, || if((temperature == 37.5) && (weight == 300)) { name =‘A’; }
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);
Image of page 7

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

View Full Document Right 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); }
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; kg2lb(kilogram, &pound) printf(“%f kilogram = %f pound\n”,kilogram,pound); }
Image of page 9

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

View Full Document Right 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.
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 short - usually 16 bit on a 16 bit or 32 bit CPU may be 8 bit on an eight bit machine .
Image of page 11

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern