Tulsanus Hurricanus Digitalus Mus Controller • EDU Processor 10 MIPS • Variable space: 2K SRAM • Program space: 32K FLASH • Serial port • Interrupts •

Slides:



Advertisements
Similar presentations
Assembly Language.
Advertisements

1 C and the 8051 EGRE Introduction The Silicon Labs ISE uses the Keil C51 compiler. The code size is limiter to 2K C has replaced PL/M (the original.
Pemrograman C Risanuri Hidayat. Why C  Compact, fast, and powerful  “Mid-level” Language  Standard for program development (wide acceptance)  It is.
Chapter 13 & 14 C Preprocessor and Other C Topics Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education.
CMSC 2021 C++ I/O and Other Topics. CMSC 2022 Using C++ Stream I/O Default input stream is called cin Default output stream is called cout Use the extraction.
Structure of a C program
1 Key Concepts:  Why C?  Life Cycle Of a C program,  What is a computer program?  A program statement?  Basic parts of a C program,  Printf() function?
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 17 - The Preprocessor Outline 17.1Introduction 17.2The #include Preprocessor Directive 17.3The.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Railway Foundation Electronic, Electrical and Processor Engineering.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction.
Symbolic Constants in CCS-2303, C-Term Digression – Symbolic Constants in C CS-2303, System Programming Concepts (Slides include materials from The.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
Railway Foundation Electronic, Electrical and Processor Engineering.
Macro & Function. Function consumes more time When a function is called, the copy of the arguments are passed to the parameters in the function. After.
Basic Elements of C++ Chapter 2.
C How to Program, 6/e © by Pearson Education, Inc. All Rights Reserved.
 2007 Pearson Education, Inc. All rights reserved C Preprocessor.
 2003 Prentice Hall, Inc. All rights reserved. 1 Chapter 19 - The Preprocessor Outline 19.1 Introduction 19.2 The #include Preprocessor Directive 19.3.
By: Mr. Baha Hanene Chapter 3. Learning Outcomes We will cover the learning outcome 02 in this chapter i.e. Use basic data-types and input / output in.
Computer Science 210 Computer Organization Introduction to C.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 12 - The Preprocessor Directives (Macros)
Program A computer program (also software, or just a program) is a sequence of instructions written in a sequence to perform a specified task with a computer.
/* Documentations */ Pre process / Linking statements Global declarations; main( ) { Local Declarations; Program statements / Executable statements; }
Data & Data Types & Simple Math Operation 1 Data and Data Type Standard I/O Simple Math operation.
Topic 3 – The General Form of a C Program. CISC 105 – Topic 3 The General Form of a C Program Now, all of the basic building blocks of a C program are.
Week 1 Algorithmization and Programming Languages.
Fundamentals of C and C++ Programming. EEL 3801 – Lotzi Bölöni Sub-Topics  Basic Program Structure  Variables - Types and Declarations  Basic Program.
CSCI 130 Chapter 3. Variables & Names Variable Declarations: –reserve a storage location in memory –identify the name of the variable –identify the type.
CSCI 171 Presentation 8 Built-in Functions, Preprocessor Directives, and Macros.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessing Lecture 12 April 7, 2005.
CC112 Structured Programming Lecture 2 1 Arab Academy for Science and Technology and Maritime Transport College of Engineering and Technology Computer.
CHAPTER # 2 Part 2 PROGRAMS AND DATA 1 st semster King Saud University College of Applied studies and Community Service CSC1101 By: Asma Alosaimi.
CS1372: HELPING TO PUT THE COMPUTING IN ECE CS1372 Some Basics.
The Software Construction Process. Computer System Components Central Processing Unit (Microprocessor)
Introduction to Algorithmic Processes CMPSC 201C Fall 2000.
 2003 Prentice Hall, Inc. All rights reserved. 1 IS 0020 Program Design and Software Tools Preprocessor Midterm Review Lecture 7 Feb 17, 2004.
Programming Fundamentals. Summary of previous lectures Programming Language Phases of C++ Environment Variables and Data Types.
TU STORM The TU STORM Robot Controller: Innovation First Mini Robot Controller (Microchip PIC18F8520) Programmable in C Using MPLAB IDE.
THE PREPROCESSOR
The Preprocessor Directives Introduction Preprocessing – Occurs before program compiled Inclusion of external files Definition of symbolic constants.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 13 - The Preprocessor Outline 13.1Introduction 13.2The #include Preprocessor Directive 13.3The.
1 Object-Oriented Programming -- Using C++ Andres, Wen-Yuan Liao Department of Computer Science and Engineering De Lin Institute of Technology
C is a high level language (HLL)
ARM Embedded Programming Lecture 4 Accessing Memory Mapped Registers.
1 C Syntax and Semantics Dr. Sherif Mohamed Tawfik Lecture Two.
ME 120: Arduino Programming Arduino Programming Part II ME 120 Mechanical and Materials Engineering Portland State University
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
1 CS 192 Lecture 4 Winter 2003 December 8-9, 2003 Dr. Shafay Shamail.
Numbers in ‘C’ Two general categories: Integers Floats
Chapter # 2 Part 2 Programs And data
Computer Science 210 Computer Organization
Arduino Programming Part II
Chapter 13 - The Preprocessor
Functions Separate Compilation
Computer Engineering 1nd Semester
The Arduino Microcontroller: Atmel AVR Atmega 328
Computer Science 210 Computer Organization
Variables In programming, we often need to have places to store data. These receptacles are called variables. They are called that because they can change.
Computer Organization & Compilation Process
Embedded C for 8051: Primer for CompEng 3150
C Preprocessor(CPP).
Preprocessor.
Chapter # 2 Part 2 Programs And data
WEEK-2.
C Preprocessor Seema Chandak.
Lab guide # 12 Review C Preprocessor And Q&A.
Computer Organization & Compilation Process
Week 5 Computers are like Old Testament gods; lots of rules and no mercy. Joseph Campbell.
Preprocessor Directives and Macros Chapter 21
Presentation transcript:

Tulsanus Hurricanus Digitalus Mus Controller • EDU Processor 10 MIPS • Variable space: 2K SRAM • Program space: 32K FLASH • Serial port • Interrupts • Timers • Direct control of the hardware

C Concepts " Modular " Powerful " Industry standard " Fast and efficient

Programming in dialect of C • No native floating point math. • No built in trig functions. • optional Assembly • Macros • GetData() • PutData() • Get_Analog_Value() function • Digital I/O (user chooses) • Sixteen 10-bit analog inputs

One project, many files… •.c-Source Files •.h-Header Files •.lib-Library Files •.lkr-Linker Scripts • Edit the.c and.h files • Compile • Link

Variables unsigned char wheel_count; /* range: 0 to 255 */ char wheel_count; /* range: -128 to 127 */ unsigned int wheel_count; /* range: 0 to */ int wheel_count; /* range: to */

unsigned int Doubled_Number (unsigned int num2double) { unsigned int result; result = 2 * num2double; return result; } Sample Function LOCAL VARIABLES CODE TO EXECUTE RETURN VALUE Sample Function

Pre-Processor Directive The # symbol denotes a pre-processor directive that is evaluated before the compiler takes over. #include “ ifi_aliases.h ” MUST be in left-most column!

#define preprocessor directive #define identifier replacement-text occurrences of identifier is replaced by replacement- text before compilation " Symbolic constants – #define PI all subsequent occurrences of symbol constant PI are replaced with – #define FIELD_WIDTH 125 – #define FIELD_LENGTH 300

#define preprocessor directive #define macro-identifier replacement-text occurrences of macro-identifier is replaced by replacement-text before compilation " Macros – #define CIRCLE_AREA(x) (PI*(x)*(x)) when CIRCLE_AREA(x) appears: " The value of x is substituted for x " Then the macro is expanded #define macro-identifier replacement-text occurrences of macro-identifier is replaced by replacement-text before compilation " Macros – #define CIRCLE_AREA(x) (PI*(x)*(x)) when CIRCLE_AREA(x) appears: " The value of x is substituted for x " Then the macro is expanded

#define preprocessor directive #define CIRCLE_AREA(x) (PI*(x)*(x)) area= CIRCLE_AREA(7) ; // becomes: area= ( * (7) *(7)); area = CIRCLE_AREA(rd +2); //becomes: area = ( * (rd+2)*(rd+2)); #define FIELD_PERIMETER FIELD_WIDTH*2+FIELD_LENGTH*2 #define CIRCLE_AREA(x) (PI*(x)*(x)) area= CIRCLE_AREA(7) ; // becomes: area= ( * (7) *(7)); area = CIRCLE_AREA(rd +2); //becomes: area = ( * (rd+2)*(rd+2)); #define FIELD_PERIMETER FIELD_WIDTH*2+FIELD_LENGTH*2

Output in C " printf("pwM01 = ",pwd, \n)