Table of Contents Introduction Target Audience What is an Embedded System? Why use the C Programming Language? Prerequisites The Approach Taken in this Book Some Good Advice
Your First C Program About the Programming Tools Downloading the DJGPP Compiler Installing the DJGPP Compiler Setting Up the DJGPP Compiler Installing the Compiler from the Elektor Website How C Programs are Created Start Programming Compiling the Program About Your First C Program Analysing the Program Characters and Strings Functions Program Statements Preprocessor Directives Whitespace Characters Exercises Solutions Summary
C Basics Setting up Programmer's Notepad Some General Settings A New Program to Compile Setting up Programmer's Notepad to Run the DJGPP Compiler A Keyboard Shortcut for the Compiler Setting Up Programmer’s Notepad to Run Programs How the sticky.c Program Works Input, Output and Variables Variables Getting Input from the User – the scanf() Function Variable Types Floating Point Variables Character Variables Arithmetic Operators Field Width Specifiers
40 40 40 43 45 47 48 50 51 53 55 57 57 58 59 61
5
C Programming for Embedded Microcontroller - Elektor - ISBN 978-0-905705-80-4
2.7 2.7.1 2.8 2.8.1 2.9 2.10 2.10.1 2.11
Compiling and Linking Some Compile and Link Experiments Errors and Warnings Compile Errors Link Errors Exercises Solutions Summary
Comparative Operators and Decisions Comparative Operators True and False Decisions Using if to Make a Decision Using else in Conjunction with if The = Operator and the == Operator Using else if in Conjunction with if Exercises Solutions Summary
71 71 71 72 73 73 75 77 79 79 80
4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.7.1 4.8
The while Loop The while Loop Using if Inside the while Loop The Guess My Number Game Back to the Temperature Controller Example Commenting Programs Programming Style Exercises Solutions Summary
Functions Your Second Function Passing Data to a Function Passing More Than One Value to a Function Passing a Variable to a Function Getting a Value Back from a Function Passing Values to a Function and Receiving a Value Back Flashing LED Simulation Program Pre-processor Directives Functions Calling Functions Using Multiple Source Files Header Files The make Program and Make File How the Make File Works
6
94 95 96 97 98 99 100 101 102 106 107 108 109 112
C Programming for Embedded Microcontroller - Elektor - ISBN 978-0-905705-80-4
5.13 5.14 5.14.1 5.15
How Functions Relate to Linking and Library Files Exercises Solutions Summary
Number Systems Binary Basics The Need for Binary Numbers Numbering Systems A Quick Look at Decimal Numbers Binary Numbers Hexadecimal Numbers Working with Hexadecimal Numbers in C Field Width Specifiers Revisited The ASCII Alphanumeric Code Exercises Solutions Summary
Memory and Microcontrollers Memory Basics A Look at a Memory Chip How Microprocessors Access Memory and Peripherals Pointers More on C Data Types Choosing a Microcontroller and Embedded System Summary
Your First Embedded C Program How Embedded Programming Differs from PC Programming The Embedded C Programming Tools The YAGARTO Toolchain Installing YAGARTO Testing the YAGARTO Installation Running Eclipse for the First Time Writing Your First Embedded Program The while(1) Loop About the Source Code Opening the Program in Eclipse Modifying the Program to Run on Your Embedded System Modifying the Make File Loading the Program to Flash Memory A Brief Explanation of the Project Files Exercises Summary
C Programming for Embedded Microcontroller - Elektor - ISBN 978-0-905705-80-4
9 9.1 9.2 9.2.1 9.3 9.4 9.5 9.6 9.6.1 9.7
Embedded I/O & Memory Maps Loading a Program into SRAM Writing to More than One LED The Program’s New C Language Elements Reading the Switches and Writing to the LEDs (I/O) The AT91SAM7S Memory Map A Closer Look at the PIO Controller Exercises Solutions Summary
The DBGU Serial Port Hardware Requirements for PC to µC Serial Communications Serial Cable USB to RS-232 Serial Adapter Programming the Serial Port About the DBGU Serial Port Hardware How the serial_tx Program Works Using the sprintf() Function Receiving Data on the Serial Port Exercises Solutions Summary
Previous C Topics Revisited Serial Port Driver Format Specifiers Escape Sequences Loops A while Loop that uses break and continue The do while Loop The for Loop Nested Loops and Decisions Decision Making with the switch Statement The Conditional Operator Functions and Pointers Returning More Than One Value from a Function Variables and Scope Global Variables Static Variables Floating Point Data Types Casts Exercises Solutions Summary
Arrays and Strings Arrays Strings Writing to a String Initialising a String C Library String Functions Arrays and Addresses Passing an Array to a Function Strings as Pointers A Look at the DBGUTxMsg() Function Multidimensional Arrays Exercises Solutions Summary
Bit Manipulation and Logical Operators Bit Manipulation with Bitwise Operators Why Do We Need Bitwise Operators? The Left and Right Shift Operators The C Assignment Operators Logical Operators Operator Precedence Exercises Solutions Summary
263 263 266 269 271 272 275 276 276 277
14 14.1 14.2 14.3 14.4 14.5
More Hardware Programming The AT91SAM7S Timer Counter The Analogue to Digital Converter (ADC) Using the Timer and Interrupt The Watchdog Timer Summary
Wrapping Up Structures Pointers to Structures Unions Enumerated Type The typedef Declarator Storage Class Specifiers Type Qualifiers The goto Statement A List of All C Keywords More Preprocessor Directives Debugging Some Final Example Programs Voltmeter
Comparison between curvature and 3D strain analysis methods for fracture predicting in the Gachsaran oil field (Iran). Shaban, A., Sherkati, S. & Miri, S. A..
additional graphics and sound, and runescript. You don't .... save the world and kill the big bad guy who has released his orc army to scour the land. Then in the.
After you have finished installing the game, you can select Pacific Fighters from your comput- ..... First of all, your bullets don't fly in a perfectly straight line. ...... Further promotion and demotion are possible (not to mention the possibility
Aug 24, 2012 - In this poignant novel, full of compassion and optimism, single mother .... Nina stops school, starts drinking too much and regrets not having a real job. ..... are seers, wizards, and charlatans and who, above all, have the power ...
Thunder Falls ...... In Wrath of the Lich King these items were, at first: Frozen Orbs and ..... There are two major locations to get Jormungar Scales from, The Storm ...
Rhino Bus escort missions (See Section III.C.5. of this report for ..... and the National Training Center (NTC), as well as in Kuwait and Iraq. (Annexes 111C, 128C,.
graphics) onto westbound Route Irish, the road to BIAP. .... (U) Route Irish is commonly referred to as âthe deadliest road in Iraqâ by ...... civilian recognition.
You can explore SQL statements, views, and aliases. ..... This way you can anticipate problems and proactively plan for them. ...... Host Environment Product Guide, which is available in PDF format on the documentation CD ...... EMC Solutions Enabler
Two slots for Type II Compact Flash Cards, each slot .... a 45° angle for easier viewing, if needed. Slide the ..... Card (page 40) inserted in the DCS Pro Back or.
directory when you want to keep several di erent versions of LE-LISP. ... directory /usr/local/bin, for instance) in the host le system. ..... Finally, you have access to the source code of a large number of utilities that are written in LISP. The ..
charcoal briquettes in the center of the charcoal grate (refer to the chart below). 7. Place the lid on the barbecue. Consult your recipe for recommended cooking.
Dec 10, 2003 - during the 21st Century (Bird, 1993; Field, 1993), attributable largely to thermal ...... occurred on September 9th, 2000, and full polarimetric L- and P-band data ...... necessarily obtained through manual measurement from ...... acco
Always in the know when it comes to fashion trends from Asia, Europe and now. America, the brothers were inspired by major brands like Gucci and Chanel for ...Termes manquants :
and copied solely for use in developing products for Palm OS software. ...... Controls allow the user to perform commands, enter options, and edit data. Table 2.2 ...