Real Time Embedded Systems. Lecture 5 January 24, 2012 Embedded C Programming
|
|
- Rudolf Lindsey
- 6 years ago
- Views:
Transcription
1 Embedded C
2 Real Time Embedded Systems Lecture 5 January 24, 2012 Embedded C Programming
3 Section Topic Where in the books Catsoulis chapter/page Simon chapter/page Zilog UM197 (ZNEO Z16F Series Flash Microcontroller Contest Kit User Manual) Zilog UM171 (ZiLOG Developer Studio II ZNEO User Manual) Zilog PS220 (ZNEO Z16F Series Product Specification) Zilog UM188 (ZNEO CPU Core User Manual) Assorted datasheets
4 Embedded Programming Whats special/different about programming embedded systems? Low level Performance concerns Robustness Tool chain Debugging, Test No OS, or limited OS Limited libraries Limited choice of languages
5 Embedded Software Development Process C file Cross Compiler Assembly file Assemble r Debugger Target Device Binary file Binary file Emulator Library Linker Executable file Programmer IDE
6 Style Lots of style guides. Pick one. No need to invent your own. Style guides often include project management style. Use this one
7 Style Variable and function names should be sufficient to understand the meaning. count, temp, time for example i,j,k are acceptable for index variables x,y,z are acceptable for coordinates Function names should take the place of verbs in the programming language
8 Tabs vs Spaces Religious arguments I like spaces, 4 for each level of indent Others argue for tabs, set for 8 characters, less file space needed Other argue for 2 spaces, more room and less spaces wasted.
9 Where to put the curly bracket Some argue on the line after the function static void function(int n) { // } Others (like me) argue for the same line: static void function(int n) { // } Learn to live with both.
10 No Other Options Stuff like this is not good style: while (PEIN&SCIO) { wait-- ; if(wait==0) { ferror(); } }
11 Always use {} Even when you don't absolutely need to. In all loops and all if/then/else if (sp>0) return val[sp] else printf( error\n ); return 0.0; if (sp>0) { return val[sp] } else { printf( error\n ); return 0.0; }
12 Makes for faster/easier fixes if (sp>0) sp += 2; return val[sp] else printf( error\n ); return 0.0; if (sp>0) { sp += 2; return val[sp] } else { printf( error\n ); return 0.0; }
13 Comments Comment the module Description, Implementation, Requirements Comment the functions Describe the function, parameters, exceptional conditions Comments the constants and globals Describe the global and who uses it Comment anything that needs explanation Particularly helpful with specific hardware requirements
14 Comments Fanciness does not help /***************************************** * * * This type of comment header is * * a royal pain to maintain, so they * * tend to be inaccurate * * * *****************************************/ /***************************************** There is nothing wrong with this and its just as easy to read and even easier to maintain *****************************************/
15 Modules/APIs Minimize coupling, dependency Use.h and.c files appropriately Naming Module LED.c, LED.h Function LED_init() LED_clear() Constants LED_BUFFER_MAX Include profuse documentation
16 .c &.h.h.c Stuff that's public like externs declarations, function prototypes and public #defines Stuff that's private (this c source file only)
17 Prevent multiple includes Some compilers support #pragma once Others don't (like the ZDS II IDE) Use a #include guard like this #ifndef _MODULE_H_ #define _MODULE_H_ //prototypes and stuff goes here #endif /* _MODULE_H_ */
18 Style You can follow one of the many style guides (like K&R) or Keep your program clear, easy to read. No bonus points for terse, confusing, most code per page, least number of comments.
19 Unless you can do stuff like this... int X=320,Y=200, n=0,m, x,y, j=1024; double T=44.0 /7,P[ ],C[5] ={ 0,3, 0,0,8},p=1, B=11.0 /630, f=0,r = 3,g =7,b =13,*q=P, D,*J; unsigned char U[66666],*v=U,*h,l[5555],c=0,*e,*a,*z; #include <math.h> #define R1(t) t=(int)(t\ * )%j; t/=j; #define Rl(C,t)\ n++[c] = t*n/12; #define RI(C) B=-B; R1\ (r)r1(g )R1(b )for(n\ =0; n<j; ){ Rl(C,r)Rl\ (C,g)Rl(C,b)++n; }
20 A Bad Example Actual Example code from a MicroChip datasheet //... void sak(void) // SAK = 0-1 { unsigned char wait=timeout ; // init "wait" variable P3DIR = 0x5a ; // P3.0 = INPUT while (P3IN&SCIO) // if SCIO = 1 { wait-- ; // decrement timeout variable if(wait==0){ferror() ;} } // if timeout, final error dlthb() ; dlthb() ; // wait a bit period if(!(p3in&scio)) // no edge inside SAK { ferror() ; } // same error inside SAK else { P3OUT = SCIO ; // set P3.0 P3DIR=0x5b ; } } // if no_error, P3.0=OUTPUT
21 Made Better //... void sak(void) { unsigned char wait=timeout; // Set P3.0 to INPUT P3DIR = 0x5a; while (P3IN&SCIO) { wait-- ; if(wait==0) { ferror() ; } } // wait a bit period dlthb() ; dlthb() ; } // no edge inside SAK if (!(P3IN&SCIO)) { ferror() ; } else { // set P3.0 P3OUT = SCIO ; P3DIR=0x5b ; }
22 Zilog/Z16 Specifics Data sizes Memory Model Call Frames Static vs Dynamic Frames Keywords Compiler settings Standard Libraries
23 Z16 Data Size We know that the exact data size in C is not specified. Current C compilers provide fairly consistent data sizes. The Z16 compiler is consistent char 1 byte short 2 bytes int 4 bytes long 4 bytes float 4 bytes double 8 bytes
24
25 Z16 Memory Architecture The Z16 has multiple blocks of memory Flash SRAM SFR External (add on)
26 Z16 Memory Map SFR External Memory Internal SRAM FF_FFFFH <- Top of IO memory FF_E000H <- Bottom of IO memory FF_C000H FF_E000H FF_BFFFH <- Top of RAM FF_xxxxH <- Bottom of RAM FF_8000H External Memory Internal FLASH Flash option bits 00_xxxxH <- Top of non-volatile 00_7FFFH 00_0xxxH 00_0000H <- Bottom of memory
27 Z16 Memory Map SFR External Memory Internal SRAM FF_FFFFH <- Top of IO memory FF_E000H <- Bottom of IO memory FF_C000H FF_E000H FF_BFFFH <- Top of RAM FF_xxxxH <- Bottom of RAM External Memory FF_8000H Device Specific Boundary Internal FLASH Flash option bits 00_xxxxH <- Top of non-volatile 00_7FFFH 00_0xxxH 00_0000H <- Bottom of memory
28 Z16 Memory Map SFR External Memory Internal SRAM External Memory Internal FLASH Flash option bits FF_FFFFH FF_E000H FF_C000H FF_E000H FF_BFFFH FF_xxxxH FF_8000H 00_xxxxH 00_7FFFH 00_0xxxH 00_0000H _Near 16 bit addressable RAM space _Far 32 bit addressable RAM space _Erom 32 bit addressable ROM space _Rom 16 bit addressable ROM space
29 Memory Access _Near Specifies that data be placed RAM in address space (16-bit address) _Far Specifies that data be placed in external RAM address space (32-bit address) _Rom Specifies that data be placed in ROM (FLASH) address space (16 or 32 but address) _Erom Specifies that data be placed in internal or external ROM (32 bit address) space
30 Settings in ZDS II
31 Memory Models The Z16 IDE supports 2 memory models: small and large. They differ in where data is placed. Choice of model size does not effect the program size much, just the space for data (and also the size of the address needed to access the data).
32 Small Memory Model Small Globals stored in RAM address space (_Near). Locals and function parameters are stored on the stack, also in RAM (_Near) space. All using 16- bit addresses. Globals can be stored in _Far, _Rom, _Erom using the a placement specifier Locals are always in RAM (_Near) and specifiers are ignored.
33 Large Memory Model Large - Globals stored in _Far address space. Locals and function parameters stored on the stack, also in _Far space. All using 32-bit addresses. Globals and static variables can be specified with _Near, _Rom, _Erom
34 Data Space near int near_data; // in RAM (16bit address) far int far_data; // in RAM (32bit address) rom int rom_data; // in ROM (in flash)
35 Memory near int List[10]; far int data[200]; rom int factors[] = {9,1,2,7,3,9,2,6}; char *thing; char far *fp; // near if small memory model // far if large memory model // the char is stored in far memory // fp is stored in near ram for small model // fp is stored in far ram for large model char rom * near charptr; // charptr is a pointer to a char in rom // charptr is stored in near ram
36 Endianness Data is stored in ZNEO memory in big endian order. The address of a multi-byte word (2 or 4 bytes) is the most significant byte.
37 Endianess Endian big First byte (lowest address) most significant Last byte (highest address) least significant little least significant most significant
38 Compiler Settings Compiler settings can be changed with #pragma directives. #pragma noopt Disables optimization. A number of ways to disable part of the optimization: nojumpopt, nolocalopt, nooptlink, nopeephole. Can also turn off optimization in IDE
39 Standard Run Time Libraries <assert.h> - Diagnostics <errno.h> - Macros for reporting error conditions <stddef.h> - Standard definitions <ctype.h> - Character handling (isanum() etc) <limits.h> - Min/Max values for various data types (INT_MAX, INT_MIN). <float.h> - Floating point limits. <math.h> - Math functions
40 Standard Run Time Library <setjmp.h> <stdarg.h> <stdio.h> <stdlib.h> <string.h> <stddef.h> - Nonlocal jumps - Variable arguments - printf, scanf, getchar, putchar IO functions - Standard types (errno.h, stddef.h, math.h, string.h). - Functions for manipulating character arrays. - Stardard defines
41 Non-standard Libraries <sio.h> - non-standard IO functions (init_uart, etc) <zneo.h> - Defines for all of the Z16 special function registers.
42 API Example Example Status.c Use the modem lights for program status indicators.
43 /******************************************************************* status.h Status Indicators December 2006 (updated for ZNEO February 2009) Dan Eisenreich Set status.c for documentation *******************************************************************/ #ifndef _STATUS_H_ #define _STATUS_H_ #define STATUS_LED1 0x01 #define STATUS_LED2 0x02 #define STATUS_LED3 0x04 #define STATUS_LED4 0x08 #define STATUS_LED_ALL 0x0F // Get the status LEDs ready to use and clear them all. void status_init(void); // Turn on LEDs void status_set(int num); // Turn off LEDs void status_clear(int num); #endif /* _STATUS_H_ */
44 #include <zneo.h> #include "status.h" /******************************************************************* status.c Status Indicators December 2006 (updated for ZNEO February 2009) Dan Eisenreich Use the 4 MODEM status LEDs on the Z8F6402 demo board as progress indicators. These are easier to use than the LED arrays (no latch) and won't interfere with text being displayed. Needs to have 4 jumper wires put in the modem socket (see below). CONFIGURATION: ============= The LEDs are mapped with wires like this: You need to add these wires v Status 1 -> PF0 -> J2 pin 25 -> wire -> J3 pin 9 -> LED D10 (TX) Status 2 -> PF1 -> J2 pin 32 -> wire -> J3 pin 8 -> LED D9 (DTR Status 3 -> PF2 -> J2 pin 28 -> wire -> J3 pin 7 -> LED D8 (RX) Status 4 -> PF3 -> J2 pin 26 -> wire -> J3 pin 6 -> LED D7 (DCD)
45 If you need more detail, look at the modem socket (connectors J2 and J3) These wires here are the ones that need to be added. J3 J2 ===== v ===== > PF > PF > PF2 D < ---/\/\/\ (-+ 29 D < ---/\/\/\ ( D < ---/\/\/\ ( D < ---/\/\/\ > PF1 V
46 You can hook these LEDs up any way you want, I chose this way so that all 4 LEDs where connected to 4 sequential bits on one IO port (port F). ********************************************************************/ /******************************************************************** status_init Configure the lower half of port F to dive these LEDs */ void status_init(void) { // Port F xxxx0000, x = leave alone, 0 = clear bit PFDD &= ~0x0F; // Set the data direction to OUT PFAF &= ~0x0F; // No alternate function PFOC &= ~0x0F; // No output control PFOUT &= ~0x0F; // Initialize them to all off }
47 /******************************************************************** status_set set (turn on) the status LEDs status_set(0) clears all LEDs status_set(0xf) turns on ALL LEDs */ void status_set(int num) { /* We could set the bits individually but thats more work. So instead we get PFOUT, clear the lower 4 bits, and reset them according to the number provided then send that back out to PFOUT. So setting 0 clears all, setting 0xF sets all. */ PFOUT = (PFOUT & 0xF0) (num & 0x0F); } /******************************************************************** status_clear clear an individual LED status_clear( 0 ) sets all LEDs status_clear(0xf) clears all */ void status_clear(int num) { } PFOUT &= ~(num & 0x0F);
48 There are some Things You Should Know now that we will discuss in detail in a few weeks. About the oscillator About the serial port
49 Set The Oscillator If you don t explicitly set the oscillator, your program will use whatever it was last set to. // unlock the oscillator control register OSCCTL = 0xE7; OSCCTL = 0x18; // follow with ONE of these TWO settings // A0 = 1010_0000 = internal 5.5 MHz OSCCTL = 0xA0; // 61 = 0110_0001 = external Hz OSCCTL = 0x61;
50 To use the serial port #include <zneo.h> #include <sio.h> #include <stdio.h> void main(void) { OSCCTL = 0xE7; OSCCTL = 0x18; OSCCTL = 0x61; // MHz init_uart(_uart0, , 57600); } printf("hello World\n");
51 On The Serial Port The CLOCK passed to the INIT_UART() should match the oscillator speed set. If they don t, you will not get the baudrate you think you should get.
52 On The Serial Port Don t forget to enable the C Runtime
53 Careful, Clear, concise coding will help you in the long run!
Systems Programming. Lecture 4 Z16 Architecture and Programming
Systems Programming www.atomicrhubarb.com/systems Lecture 4 Z16 Architecture and Programming Section Topic Where in the books Zilog Zilog Zilog Zilog UM197 (ZNEO Z16F Series Flash Microcontroller Contest
More informationReal Time Embedded Systems. Lecture 1 January 17, 2012
Low-Power & Reset Real Time Embedded Systems www.atomicrhubarb.com/embedded Lecture 1 January 17, 2012 Topic Section Topic Where in the books Catsoulis chapter/page Simon chapter/page Zilog UM197 (ZNEO
More informationReal Time Embedded Systems. Lecture 10 January 31, 2012 Interrupts
Interrupts Real Time Embedded Systems www.atomicrhubarb.com/embedded Lecture 10 January 31, 2012 Interrupts Section Topic Where in the books Catsoulis chapter 1 (pg 10-12) Simon chapter4 Zilog UM197 (ZNEO
More informationWriting an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and
Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and #include The Use of printf() and scanf() The Use of printf()
More informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science
Language Design COMS W4115 Prof. Stephen A. Edwards Spring 2003 Columbia University Department of Computer Science Language Design Issues Syntax: how programs look Names and reserved words Instruction
More informationC Review. MaxMSP Developers Workshop Summer 2009 CNMAT
C Review MaxMSP Developers Workshop Summer 2009 CNMAT C Syntax Program control (loops, branches): Function calls Math: +, -, *, /, ++, -- Variables, types, structures, assignment Pointers and memory (***
More informationBIL 104E Introduction to Scientific and Engineering Computing. Lecture 4
BIL 104E Introduction to Scientific and Engineering Computing Lecture 4 Introduction Divide and Conquer Construct a program from smaller pieces or components These smaller pieces are called modules Functions
More informationExercise Session 2 Simon Gerber
Exercise Session 2 Simon Gerber CASP 2014 Exercise 2: Binary search tree Implement and test a binary search tree in C: Implement key insert() and lookup() functions Implement as C module: bst.c, bst.h
More informationUsing peripherals on the MSP430 (if time)
Today's Plan: Announcements Review Activities 1&2 Programming in C Using peripherals on the MSP430 (if time) Activity 3 Announcements: Midterm coming on Feb 9. Will need to write simple programs in C and/or
More informationLanguage Design COMS W4115. Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science
Language Design COMS W4115 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Prof. Stephen A. Edwards Fall 2006 Columbia University Department of Computer Science Language Design
More informationReal Time Embedded Systems. Lecture 1 January 17, 2012
SPI 4-Wire 3-Wire Real Time Embedded Systems www.atomicrhubarb.com/embedded Lecture 1 January 17, 2012 Topic Section Topic Where in the books Catsoulis chapter/page Simon chapter/page Zilog UM197 (ZNEO
More informationTutorial 5. PDS Lab Section 16 Autumn Functions The C language is termed as function-oriented programming
PDS Lab Section 16 Autumn-2018 Tutorial 5 Functions The C language is termed as function-oriented programming Every C program consists of one or more functions. The concept is based on the divide-and conquer
More informationLecture 03 Bits, Bytes and Data Types
Lecture 03 Bits, Bytes and Data Types Computer Languages A computer language is a language that is used to communicate with a machine. Like all languages, computer languages have syntax (form) and semantics
More informationZiLOG Z8 Encore! Compiler Compliance With ANSI STANDARD C
ZiLOG Z8 Encore! Compiler Compliance With ANSI STANDARD C ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA 95126 Telephone: 408.558.8500 Fax: 408.558.8300 www.zilog.com 2 Abstract The purpose
More informationHoltek C and ANSI C Feature Comparison User s Guide
Holtek C and ANSI C Feature Comparison User s Guide July 2009 Copyright 2009 by HOLTEK SEMICONDUCTOR INC. All rights reserved. Printed in Taiwan. No part of this publication may be reproduced, stored in
More informationECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O
ECE2049-E17 Lecture 4 1 ECE2049 E17 Lecture 4 MSP430 Architecture & Intro to Digital I/O Administrivia Homework 1: Due today by 7pm o Either place in box in ECE office or give to me o Office hours tonight!
More informationData Type Fall 2014 Jinkyu Jeong
Data Type Fall 2014 Jinkyu Jeong (jinkyu@skku.edu) 1 Syntax Rules Recap. keywords break double if sizeof void case else int static... Identifiers not#me scanf 123th printf _id so_am_i gedd007 Constants
More informationWeek 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals. Alvin Valera. School of Engineering and Computer Science Victoria University of Wellington
Week 1 / Lecture 2 8 March 2017 NWEN 241 C Fundamentals Alvin Valera School of Engineering and Computer Science Victoria University of Wellington Admin stuff People Course Coordinator Lecturer Alvin Valera
More informationDr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)
Lecture 9 Functions Dr M Kasim A Jalil Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson) Objectives In this chapter, you will learn: To understand how to construct programs modularly
More informationTechnical Questions. Q 1) What are the key features in C programming language?
Technical Questions Q 1) What are the key features in C programming language? Portability Platform independent language. Modularity Possibility to break down large programs into small modules. Flexibility
More informationTopic 6: A Quick Intro To C
Topic 6: A Quick Intro To C Assumption: All of you know Java. Much of C syntax is the same. Also: Many of you have used C or C++. Goal for this topic: you can write & run a simple C program basic functions
More informationTopic 6: A Quick Intro To C. Reading. "goto Considered Harmful" History
Topic 6: A Quick Intro To C Reading Assumption: All of you know basic Java. Much of C syntax is the same. Also: Some of you have used C or C++. Goal for this topic: you can write & run a simple C program
More informationThe C Language Reference Manual
The C Language Reference Manual Stephen A. Edwards Columbia University Summer 2014 Katsushika Hokusai, In the Hollow of a Wave off the Coast at Kanagawa, 1827 Part I The History of C C History Developed
More informationA function is a named piece of code that performs a specific task. Sometimes functions are called methods, procedures, or subroutines (like in LC-3).
CIT Intro to Computer Systems Lecture # (//) Functions As you probably know from your other programming courses, a key part of any modern programming language is the ability to create separate functions
More informationCMPE-013/L. Introduction to C Programming
CMPE-013/L Introduction to C Programming Bryant Wenborg Mairs Spring 2014 What we will cover in 13/L Embedded C on a microcontroller Specific issues with microcontrollers Peripheral usage Reading documentation
More informationProgramming in C Quick Start! Biostatistics 615 Lecture 4
Programming in C Quick Start! Biostatistics 615 Lecture 4 Last Lecture Analysis of Algorithms Empirical Analysis Mathematical Analysis Big-Oh notation Today Basics of programming in C Syntax of C programs
More informationA Fast Review of C Essentials Part I
A Fast Review of C Essentials Part I Structural Programming by Z. Cihan TAYSI Outline Program development C Essentials Functions Variables & constants Names Formatting Comments Preprocessor Data types
More informationCS6202 - PROGRAMMING & DATA STRUCTURES UNIT I Part - A 1. W hat are Keywords? Keywords are certain reserved words that have standard and pre-defined meaning in C. These keywords can be used only for their
More informationReview Activity 1 CALL and RET commands in assembler
Today's Plan: Announcements Review Activity 1 CALL and RET commands in assembler Lecture test Programming in C continue Announcements: Projects: should be starting to think about. You will need to provide
More informationCS113: Lecture 7. Topics: The C Preprocessor. I/O, Streams, Files
CS113: Lecture 7 Topics: The C Preprocessor I/O, Streams, Files 1 Remember the name: Pre-processor Most commonly used features: #include, #define. Think of the preprocessor as processing the file so as
More informationBLM2031 Structured Programming. Zeyneb KURT
BLM2031 Structured Programming Zeyneb KURT 1 Contact Contact info office : D-219 e-mail zeynebkurt@gmail.com, zeyneb@ce.yildiz.edu.tr When to contact e-mail first, take an appointment What to expect help
More informationProgram Organization and Comments
C / C++ PROGRAMMING Program Organization and Comments Copyright 2013 Dan McElroy Programming Organization The layout of a program should be fairly straight forward and simple. Although it may just look
More informationBasic C Programming. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island
Basic C Programming Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island Announcements Exam 1 (20%): Feb. 27 (Tuesday) Tentative Proposal Deadline:
More informationprintf( Please enter another number: ); scanf( %d, &num2);
CIT 593 Intro to Computer Systems Lecture #13 (11/1/12) Now that we've looked at how an assembly language program runs on a computer, we're ready to move up a level and start working with more powerful
More informationOBJECTIVE QUESTIONS: Choose the correct alternative:
OBJECTIVE QUESTIONS: Choose the correct alternative: 1. Function is data type a) Primary b) user defined c) derived d) none 2. The declaration of function is called a) function prototype b) function call
More informationComputer Programming. The greatest gift you can give another is the purity of your attention. Richard Moss
Computer Programming The greatest gift you can give another is the purity of your attention. Richard Moss Outline Modular programming Modularity Header file Code file Debugging Hints Examples T.U. Cluj-Napoca
More informationComputer Systems Lecture 9
Computer Systems Lecture 9 CPU Registers in x86 CPU status flags EFLAG: The Flag register holds the CPU status flags The status flags are separate bits in EFLAG where information on important conditions
More informationProgramming Fundamentals for Engineers Functions. Muntaser Abulafi Yacoub Sabatin Omar Qaraeen. Modular programming.
Programming Fundamentals for Engineers - 0702113 7. Functions Muntaser Abulafi Yacoub Sabatin Omar Qaraeen 1 Modular programming Your program main() function Calls AnotherFunction1() Returns the results
More informationCSE123. Program Design and Modular Programming Functions 1-1
CSE123 Program Design and Modular Programming Functions 1-1 5.1 Introduction A function in C is a small sub-program performs a particular task, supports the concept of modular programming design techniques.
More informationWhy embedded systems?
MSP430 Intro Why embedded systems? Big bang-for-the-buck by adding some intelligence to systems. Embedded Systems are ubiquitous. Embedded Systems more common as prices drop, and power decreases. Which
More informationIntroduction to C Language
Introduction to C Language Instructor: Professor I. Charles Ume ME 6405 Introduction to Mechatronics Fall 2006 Instructor: Professor Charles Ume Introduction to C Language History of C Language In 1972,
More informationIntroduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang
Introduction to C CMSC 104 Spring 2014, Section 02, Lecture 6 Jason Tang Topics History of Programming Languages Compilation Process Anatomy of C CMSC 104 Coding Standards Machine Code In the beginning,
More informationECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class)
ECE2049 Homework #2 The MSP430 Architecture & Basic Digital IO (DUE Friday 9/8/17 at 4 pm in class) Your homework should be neat and professional looking. You will loose points if your HW is not properly
More informationECEN 449 Microprocessor System Design. Review of C Programming
ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh es programming g skills s 2 1 Basic C program structure # include
More informationC Tutorial: Part 1. Dr. Charalampos C. Tsimenidis. Newcastle University School of Electrical and Electronic Engineering.
C Tutorial: Part 1 Dr. Charalampos C. Tsimenidis Newcastle University School of Electrical and Electronic Engineering September 2013 Why C? Small (32 keywords) Stable Existing code base Fast Low-level
More informationFundamental Data Types. CSE 130: Introduction to Programming in C Stony Brook University
Fundamental Data Types CSE 130: Introduction to Programming in C Stony Brook University Program Organization in C The C System C consists of several parts: The C language The preprocessor The compiler
More informationCS Programming In C
CS 24000 - Programming In C Week Two: Basic C Program Organization and Data Types Zhiyuan Li Department of Computer Science Purdue University, USA 2 int main() { } return 0; The Simplest C Program C programs
More informationUsing the ZiLOG Xtools Z8 Encore! C Compiler
Using the ZiLOG Xtools Z8 Encore! C Compiler ZiLOG Worldwide Headquarters 532 Race Street San Jose, CA 95126 Telephone: 408.558.8500 Fax: 408.558.8300 www.zilog.com Abstract The Xtools Z8 Encore! C compiler
More informationRule 1-3: Use white space to break a function into paragraphs. Rule 1-5: Avoid very long statements. Use multiple shorter statements instead.
Chapter 9: Rules Chapter 1:Style and Program Organization Rule 1-1: Organize programs for readability, just as you would expect an author to organize a book. Rule 1-2: Divide each module up into a public
More informationCS16 Exam #1 7/17/ Minutes 100 Points total
CS16 Exam #1 7/17/2012 75 Minutes 100 Points total Name: 1. (10 pts) Write the definition of a C function that takes two integers `a` and `b` as input parameters. The function returns an integer holding
More informationPart 1: Introduction to the C Language
Part 1: Introduction to the C Language 1 Dennis Ritchie originally developed C at Bell Labs to write the UNIX operating system, 1974. C was designed to provide low level access to the hardware, which an
More informationCSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community
CSCI-243 Exam 1 Review February 22, 2015 Presented by the RIT Computer Science Community http://csc.cs.rit.edu History and Evolution of Programming Languages 1. Explain the relationship between machine
More informationC Functions. CS 2060 Week 4. Prof. Jonathan Ventura
CS 2060 Week 4 1 Modularizing Programs Modularizing programs in C Writing custom functions Header files 2 Function Call Stack The function call stack Stack frames 3 Pass-by-value Pass-by-value and pass-by-reference
More informationProject Final Report Bluetooth Camera Sensor. Project Abstract. Status. Specification
Project Final Report Bluetooth Camera Sensor 04/21/2011 Yichao Yu Project Abstract There are many ways to control a robot. I m thinking why we cannot just use a common portable device as a remote controller
More informationPhysics 2660: Fundamentals of Scientific Computing. Lecture 3 Instructor: Prof. Chris Neu
Physics 2660: Fundamentals of Scientific Computing Lecture 3 Instructor: Prof. Chris Neu (chris.neu@virginia.edu) Announcements Weekly readings will be assigned and available through the class wiki home
More informationINTRODUCTION TO C++ FUNCTIONS. Dept. of Electronic Engineering, NCHU. Original slides are from
INTRODUCTION TO C++ FUNCTIONS Original slides are from http://sites.google.com/site/progntut/ Dept. of Electronic Engineering, NCHU Outline 2 Functions: Program modules in C Function Definitions Function
More informationThe C standard library
C introduction The C standard library The C standard library 1 / 12 Contents Do not reinvent the wheel Useful headers Man page The C standard library 2 / 12 The Hitchhiker s Guide to the standard library
More informationFunctions. Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.
Functions Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan 2009 Fall Outline 5.1 Introduction 5.3 Math Library Functions 5.4 Functions 5.5
More informationECEN 449 Microprocessor System Design. Review of C Programming. Texas A&M University
ECEN 449 Microprocessor System Design Review of C Programming 1 Objectives of this Lecture Unit Review C programming basics Refresh programming skills 2 Basic C program structure # include main()
More informationMPATE-GE 2618: C Programming for Music Technology. Unit 4.1
MPATE-GE 2618: C Programming for Music Technology Unit 4.1 Memory Memory in the computer can be thought of as a long string of consecutive bytes. Each byte has a corresponding address. When we declare
More informationProgramming Fundamentals (CS 302 ) Dr. Ihsan Ullah. Lecturer Department of Computer Science & IT University of Balochistan
Programming Fundamentals (CS 302 ) Dr. Ihsan Ullah Lecturer Department of Computer Science & IT University of Balochistan 1 Outline p Introduction p Program development p C language and beginning with
More informationMatlab? Chapter 3-4 Matlab and IPT Basics. Working Environment. Matlab Demo. Array. Data Type. MATLAB Desktop:
Matlab? Lecture Slides ME 4060 Machine Vision and Vision-based Control Chapter 3-4 Matlab and IPT Basics By Dr. Debao Zhou 1 MATric LABoratory data analysis, prototype and visualization Matrix operation
More informationEmbedded Systems - FS 2018
Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Sample solution to Lab 0 Date : 28.2.2018 Prelab Filling the gaps Goals of this Lab You are expected
More informationCSCI 171 Chapter Outlines
Contents CSCI 171 Chapter 1 Overview... 2 CSCI 171 Chapter 2 Programming Components... 3 CSCI 171 Chapter 3 (Sections 1 4) Selection Structures... 5 CSCI 171 Chapter 3 (Sections 5 & 6) Iteration Structures
More informationCMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 12, FALL 2012
CMSC 313 COMPUTER ORGANIZATION & ASSEMBLY LANGUAGE PROGRAMMING LECTURE 12, FALL 2012 TOPICS TODAY Assembling & Linking Assembly Language Separate Compilation in C Scope and Lifetime LINKING IN ASSEMBLY
More informationCompiling and Running a C Program in Unix
CPSC 211 Data Structures & Implementations (c) Texas A&M University [ 95 ] Compiling and Running a C Program in Unix Simple scenario in which your program is in a single file: Suppose you want to name
More informationLecture test next week
Lecture test next week Write a short program in Assembler doing. You will be given the print outs of all the assembler programs from the manual You can bring any notes you want Today: Announcements General
More informationL2 - C language for Embedded MCUs
Formation C language for Embedded MCUs: Learning how to program a Microcontroller (especially the Cortex-M based ones) - Programmation: Langages L2 - C language for Embedded MCUs Learning how to program
More informationWhy Pointers. Pointers. Pointer Declaration. Two Pointer Operators. What Are Pointers? Memory address POINTERVariable Contents ...
Why Pointers Pointers They provide the means by which functions can modify arguments in the calling function. They support dynamic memory allocation. They provide support for dynamic data structures, such
More informationThe C Programming Language Guide for the Robot Course work Module
The C Programming Language Guide for the Robot Course work Module Eric Peasley 2018 v6.4 1 2 Table of Contents Variables...5 Assignments...6 Entering Numbers...6 Operators...7 Arithmetic Operators...7
More informationTHE C STANDARD LIBRARY & MAKING YOUR OWN LIBRARY. ISA 563: Fundamentals of Systems Programming
THE C STANDARD LIBRARY & MAKING YOUR OWN LIBRARY ISA 563: Fundamentals of Systems Programming Announcements Homework 2 posted Homework 1 due in two weeks Typo on HW1 (definition of Fib. Sequence incorrect)
More informationSlide Set 5. for ENCM 339 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary
Slide Set 5 for ENCM 339 Fall 2016 Steve Norman, PhD, PEng Electrical & Computer Engineering Schulich School of Engineering University of Calgary October 2016 ENCM 339 Fall 2016 Slide Set 5 slide 2/32
More informationthe gamedesigninitiative at cornell university Lecture 7 C++ Overview
Lecture 7 Lecture 7 So You Think You Know C++ Most of you are experienced Java programmers Both in 2110 and several upper-level courses If you saw C++, was likely in a systems course Java was based on
More informationFunctions in C C Programming and Software Tools
Functions in C C Programming and Software Tools N.C. State Department of Computer Science Functions in C Functions are also called subroutines or procedures One part of a program calls (or invokes the
More informationembos Real Time Operating System CPU & Compiler specifics for RENESAS M16C CPUs and HEW workbench Document Rev. 1
embos Real Time Operating System CPU & Compiler specifics for RENESAS M16C CPUs and HEW workbench Document Rev. 1 A product of SEGGER Microcontroller GmbH & Co. KG www.segger.com 2/28 embos for M16C CPUs
More informationExperiment 9: Using HI-TECH C Compiler in MPLAB
University of Jordan Faculty of Engineering and Technology Department of Computer Engineering Embedded Systems Laboratory 0907334 9 Experiment 9: Using HI-TECH C Compiler in MPLAB Objectives The main objectives
More informationReminder: compiling & linking
Reminder: compiling & linking source file 1 object file 1 source file 2 compilation object file 2 library object file 1 linking (relocation + linking) load file source file N object file N library object
More informationEPM900 - Overview. Features. Technical Data
Page 1 of 25 EPM900 - Overview The Keil EPM900 supports in-circuit debugging and parallel Flash ROM programming for the Philips P89LPC9xx device family. EPM900 connects directly to the µvision2 Debugger
More informationfrom Appendix B: Some C Essentials
from Appendix B: Some C Essentials tw rev. 22.9.16 If you use or reference these slides or the associated textbook, please cite the original authors work as follows: Toulson, R. & Wilmshurst, T. (2016).
More informationIMPORTANT QUESTIONS IN C FOR THE INTERVIEW
IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.
More informationC-Programming. CSC209: Software Tools and Systems Programming. Paul Vrbik. University of Toronto Mississauga
C-Programming CSC209: Software Tools and Systems Programming Paul Vrbik University of Toronto Mississauga https://mcs.utm.utoronto.ca/~209/ Adapted from Dan Zingaro s 2015 slides. Week 2.0 1 / 19 What
More informationMemory and C/C++ modules
Memory and C/C++ modules From Reading #5 and mostly #6 More OOP topics (templates; libraries) as time permits later Program building l Have: source code human readable instructions l Need: machine language
More informationOutline. Computer programming. Debugging. What is it. Debugging. Hints. Debugging
Outline Computer programming Debugging Hints Gathering evidence Common C errors "Education is a progressive discovery of our own ignorance." Will Durant T.U. Cluj-Napoca - Computer Programming - lecture
More informationCSE / ENGR 142 Programming I
CSE / ENGR 142 Programming I Variables, Values, and Types Chapter 2 Overview Chapter 2: Read Sections 2.1-2.6, 2.8. Long chapter, short snippets on many topics Later chapters fill in detail Specifically:
More informationembos Real Time Operating System CPU & Compiler specifics for RENESAS M16C CPUs and IAR compiler Document Rev. 5
embos Real Time Operating System CPU & Compiler specifics for RENESAS M16C CPUs and IAR compiler Document Rev. 5 A product of SEGGER Microcontroller GmbH & Co. KG www.segger.com 2/28 embos for M16C CPUs
More informationProgramming. Data Structure
Programming & Data Structure For Computer Science & Information Technology By www.thegateacademy.com Syllabus Syllabus for Programming and Data Structures Programming in C, Arrays, Stacks, Queues, Linked
More informationLecture 13: more class, C++ memory management
CIS 330: / / / / (_) / / / / _/_/ / / / / / \/ / /_/ / `/ \/ / / / _/_// / / / / /_ / /_/ / / / / /> < / /_/ / / / / /_/ / / / /_/ / / / / / \ /_/ /_/_/_/ _ \,_/_/ /_/\,_/ \ /_/ \ //_/ /_/ Lecture 13:
More informationEmbedded Systems - FS 2018
Institut für Technische Informatik und Kommunikationsnetze Prof. L. Thiele Embedded Systems - FS 2018 Lab 0 Date : 28.2.2018 Prelab Filling the gaps Goals of this Lab You are expected to be already familiar
More informationNumber Systems, Scalar Types, and Input and Output
Number Systems, Scalar Types, and Input and Output Outline: Binary, Octal, Hexadecimal, and Decimal Numbers Character Set Comments Declaration Data Types and Constants Integral Data Types Floating-Point
More informationCOMP3221: Microprocessors and. and Embedded Systems. Instruction Set Architecture (ISA) What makes an ISA? #1: Memory Models. What makes an ISA?
COMP3221: Microprocessors and Embedded Systems Lecture 2: Instruction Set Architecture (ISA) http://www.cse.unsw.edu.au/~cs3221 Lecturer: Hui Wu Session 2, 2005 Instruction Set Architecture (ISA) ISA is
More informationECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives:
ECGR 4101/5101, Fall 2016: Lab 1 First Embedded Systems Project Learning Objectives: This lab will introduce basic embedded systems programming concepts by familiarizing the user with an embedded programming
More informationAIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session ) Contents
AIR FORCE SCHOOL,BAMRAULI COMPUTER SCIENCE (083) CLASS XI Split up Syllabus (Session- 2017-18) Month July Contents UNIT 1: COMPUTER FUNDAMENTALS Evolution of computers; Basics of computer and its operation;
More informationFunctions. Systems Programming Concepts
Functions Systems Programming Concepts Functions Simple Function Example Function Prototype and Declaration Math Library Functions Function Definition Header Files Random Number Generator Call by Value
More informationTwo s Complement Review. Two s Complement Review. Agenda. Agenda 6/21/2011
Two s Complement Review CS 61C: Great Ideas in Computer Architecture (Machine Structures) Introduction to C (Part I) Instructor: Michael Greenbaum http://inst.eecs.berkeley.edu/~cs61c/su11 Suppose we had
More informationB.V. Patel Institute of Business Management, Computer & Information Technology, Uka Tarsadia University
Unit 1 Programming Language and Overview of C 1. State whether the following statements are true or false. a. Every line in a C program should end with a semicolon. b. In C language lowercase letters are
More informationSTUDENT NAME(s):. STUDENT NUMBER(s): B00.
ECED3204 Lab #5 STUDENT NAME(s):. STUDENT NUMBER(s): B00. Pre Lab Information It is recommended that you read this entire lab ahead of time. Doing so will save you considerable time during the lab, as
More information1996 Microprocessor Development Systems
User s Guide 1996 Microprocessor Development Systems Printed in U.S.A., April 1996 2547306-9761 revision C * SPNU022C User s Guide 1996 TMS370 and TMS370C8 8-Bit Microcontroller Family Optimizing C Compiler
More informationProgramming in C. What is C?... What is C?
C Programming in C UVic SEng 265 Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More informationProgramming in C UVic SEng 265
Programming in C UVic SEng 265 Daniel M. German Department of Computer Science University of Victoria 1 SEng 265 dmgerman@uvic.ca C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier,
More informationProgramming in C. What is C?... What is C?
Programming in C UVic SEng 265 C Developed by Brian Kernighan and Dennis Ritchie of Bell Labs Earlier, in 1969, Ritchie and Thompson developed the Unix operating system We will be focusing on a version
More information