📄 developing embedded software in c -- jonathan w_ valvano.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0049)http://www.ece.utexas.edu/~valvano/embed/toc1.htm -->
<HTML><HEAD><TITLE>Developing Embedded Software in C -- Jonathan W. Valvano</TITLE>
<META http-equiv=content-type content=text/html;charset=iso-8859-1>
<META content="MSHTML 5.50.3825.1300" name=GENERATOR>
<META
content="StarMax HD:Microsoft Office 98:Templates:Web Pages:Blank Web Page"
name=Template></HEAD>
<BODY vLink=#800080 link=#0000ff>
<P><!--Developing Embedded Software in C using ICC11/ICC12/Hiware by Jonathan W. Valvano--><B><FONT
face=Helvetica,Arial size=4>Developing Embedded Software in C Using
ICC11/ICC12/Hiware </FONT></B></P>
<P><B><I><FONT face=Helvetica,Arial>Jonathan W. Valvano</FONT></I></B></P>
<DIR>
<DIR>
<P><FONT face="Times New Roman,Times"><A
href="http://www.ece.utexas.edu/~valvano/embed/chap1/chap1.htm">Chapter 1:
Program Structure</A><BR>A sample program introduces C <BR>C is a free field
language <BR>Precedence of the operator determines the order of
operation<BR>Comments are used to document the software <BR>Prepreocessor
directives are special operations that occur first <BR>Global declarations
provide modular building blocks <BR>Declarations are the basic operations
<BR>Function declarations allow for one routine to call another <BR>Compound
statements are the more complex operations <BR>Global variables are permanent
and can be shared <BR>Local variables are temporary and are private <BR>Source
files make it easier to maintain large projects<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap2/chap2.htm">Chapter 2:
Tokens</A><BR>ASCII characters <BR>Literals include numbers characters and
strings <BR>Keywords are predefined <BR>Names are user<BR>defined
<BR>Punctuation marks <BR>Operators <BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap3/chap3.htm">Chapter 3:
Literals include numbers characters and strings</A><BR>How are numbers
represented on the computer <BR>8-bit unsigned numbers <BR>8-bit signed
numbers<BR>16-bit unsigned numbers <BR>16-bit signed numbers<BR>Big and little
endian <BR>Boolean (true/false) <BR>Decimal numbers <BR>Hexadecimal numbers
<BR>Octal numbers <BR>Characters <BR>Strings<BR>Escape sequences<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap4/chap4.htm">Chapter 4:
Variables</A><BR>A static variable exists permanently <BR>A static global can be
accessed only from within the same file <BR>A static local can be accessed only
in the function<BR>We specify volatile variables when using interrupts and I/O
ports <BR>Automatic variables are allocated on the stack<BR>We can understand
automatics by looking at the assembly code <BR>A constant local can not be
changed <BR>External variables are defined elsewhere <BR>The scope of a variable
defines where it can be accessed <BR>Variables declarations <BR>8-bit variables
are defined with char <BR>Discussion of when to use static versus automatic
variables<BR>Initialization of variables and constants<BR>We can understand
initialization by looking at the assembly code<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap5/chap5.htm">Chapter 5:
Expressions</A><BR>Precedence and associativity<BR>Unary operators<BR>Binary
operators<BR>Assignment operators<BR>Expression type and explicit
casting<BR>Selection operator<BR>Arithmetic overflow and underflow<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap6/chap6.htm">Chapter 6: Flow
of Control</A><BR>Simple statements<BR>Compound statements<BR>if and if-else
statements<BR>switch statements<BR>while statements<BR>for statements<BR>do
statements<BR>return statements<BR>goto statements<BR>Null statements<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap7/chap7.htm">Chapter 7:
Pointers</A><BR>Definitions of address and pointer <BR>Declarations of pointers
define the type and allocate space in memory <BR>How do we use
pointers<BR>Memory architecture of the 6811 and 6812 <BR>Pointer math<BR>Pointer
comparisons<BR>FIFO queue implemented with pointers <BR>I/O port access <BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap8/chap8.htm">Chapter 8:
Arrays and Strings </A><BR>Array Subscripts<BR>Array Declarations<BR>Array
References<BR>Pointers and Array Names<BR>Negative Subscripts<BR>Address
Arithmetic<BR>String Functions defined in string.h<BR>Fifo Queue Example<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap9/chap9.htm">Chapter 9:
Structures</A><BR>Structure Declarations<BR>Accessing elements of a
structure<BR>Initialization of structure data<BR>Using pointers to access
structures<BR>Passing structures as parameters to functions<BR>Example of
MC68HC812A4 extended addressing<BR>Example of a Linear Linked List<BR>Example of
a Huffman Code<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap10/chap10.htm">Chapter 10:
Functions</A><BR>Function Declarations<BR>Function Definitions<BR>Function
Calls<BR>Parameter Passing<BR>Making our C programs "look like" C++<BR>Stack
frame created by ICC11 and ICC12<BR>Animation of ICC12 function call<BR>Finite
State Machine using Function Pointers<BR>Linked list interpreter<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap11/chap11.htm">Chapter 11:
Preprocessor Directives</A><BR>Using #define to create macros<BR>Using #ifdef to
implement conditional compilation<BR>Using #include to load other software
modules<BR>Using #pragma to write interrupt software<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/chap12/chap12.htm">Chapter 12:
Assembly Language</A><BR>How to insert single assembly instructions<BR>How to
compile with a mixture of assembly and C files<BR>Assembler Directives<BR>How to
use assembly to optimize a C function<BR><A
href="http://www.ece.utexas.edu/~valvano/embed/app1/app1.htm">Appendix 1: Kevin
Ross BDM - Adapt812 Interface</A><BR>Kevin Ross's Background Debug Module
<BR>ICC12 options menu for developing software for the Adapt812 <BR>Adapt 812
Board Jumpers <BR>What you need to get started <BR>Development Procedure <BR>Web
sites for more information<A
href="http://www.ece.utexas.edu/~valvano/embed/app1/app1.htm"><BR></A></FONT></P></DIR></DIR>
<P><B><I><FONT face=Helvetica,Arial>Chapter 0 The Preface</FONT></I></B></P>
<P><FONT face="Times New Roman,Times">Zero is an appropriate place for a book on
C to start. Zero has many special meanings to the C programmer. On the 6812,
zero is the address of Port A. On the 6811 zero is the first address in RAM. The
compiler will initialize all global variables to zero on start-up. We use a zero
to signify the end of a string. A pointer with a zero value is considered a
null-pointer (doesn't point to anything). We use a zero value to signify the
boolean false, and true is any nonzero value. The array subscripts in C start
with zero.</FONT></P>
<P><FONT face="Times New Roman,Times">This document serves as an introduction to
C programming on the Motorola 6811 and 6812 microcomputers. Its purpose is to
provide a short introduction to C programming using the Hiware and ImageCraft
ICC11 or ICC12 compilers (contact ImageCraft, 706 Colorado Ave. Suite 10-88,
Palo Alto, CA 94303 or see <A
href="http://www.imagecraft.com/">http://www.imagecraft.com/</A>) (contact
Hiware Inc., 5808 Brown Rock Trail, Austin, TX 78749, phone: (512) 301 4500,
fax: (512) 301 0957, or see <A
href="http://www.hiware.com/">http://www.hiware.com/</A>). While the
ICC11/ICC12/Hiware manuals explain how to use their compilers, this document
explains how to program in C for the Motorola 6811 and 6812. This document was
written with a special emphasis on embedded systems. My philosophy about C
compilers for the 6811/6812 is that there are three groups of engineers<BR>a) I
define a beginner as one who is developing very small programs (less than 1K
bytes) with no budget (like a student). In this situation a free compiler is a
requirement. Thus, the demo version of Hiware, or the freeware ICC11 version 1
could be used.<BR>b) Next in the progression is the intermediate programmer.
This engineer has a budget, but it is very small. The object code size is larger
than 1K bytes. Because these projects tend to involve a small number of
engineers, the learning curve needs to be short. Because of the limited scope of
the project, more time is spent on original coding/debugging and less time on
software maintanence. In this situation, the low cost ICC11/ICC12 can be
used.<BR>c) For the professional developer, the software projects are large and
have a high percentage of time allocated to maintanence, rather than original
coding/debugging. For this environment, either ICC11/ICC12 or the full version
of Hiware is appropriate.</FONT></P>
<P><FONT face="Times New Roman,Times">This document differs from classical C
programming books in its emphasis on embedded systems. While reviewing the
existing literature on C programming I was stuck by the high percentage of
programming examples in these books that reply on the functions <B>scanf</B> and
<B>printf</B> to perform input/output. While I/O is extremely important for
embedded systems, rarely is serial I/O with <B>scanf</B> and <B>printf</B> an
important aspect of an embedded system. This HTML document is clearly not
comprehensive rather it serves as a short refresher for those C programmers
whose skills are a little rusty. This document also assists the experienced
programmer trained in another language like Pascal or C++, that now wishes to
program in C for an embedded 6811 or 6812 system. If the reader in interested in
a more classical approach to C programming I suggest:</FONT></P>
<P><U><FONT face="Times New Roman,Times">A Book on C: Programming in
C</FONT></U><FONT face="Times New Roman,Times">, by Kelley and Pohl,
Addison-Wesley</FONT></P>
<P><FONT face="Times New Roman,Times">Send comments and suggestions about this
document to: <I><A
href="mailto:valvano@uts.cc.utexas.edu">valvano@uts.cc.utexas.edu</A></I></FONT></P>
<P><FONT face="Times New Roman,Times">The style and structure of this HTML
document was derived from <U>A Small C Compiler: Language, Usage, Theory, and
Design</U>, by James E. Hendrix. </FONT></P>
<P><IMG height=32
src="Developing Embedded Software in C -- Jonathan W_ Valvano.files/MacApple.gif"
width=60>This book was created on a Macintosh.</P>
<P><FONT face="Times New Roman,Times">Please do not distribute this document to
others. Rather it is part of the software that accompanies the book, </FONT></P>
<P><U><FONT face="Times New Roman,Times">Embedded Microcomputer Systems: Real
Time Interfacing</FONT></U><FONT face="Times New Roman,Times"> by Jonathan W.
Valvano, Brooks/Cole Publishing Co., copyright (c) 2000.</FONT></P>
<P><FONT face="Times New Roman,Times"><A
href="http://www.ece.utexas.edu/~valvano/embed/legal.htm">Legal
Statement</A></FONT></P></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -