Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Embedded microcomputer systems : real time interfacing
PREMIUM
Số trang
822
Kích thước
12.7 MB
Định dạng
PDF
Lượt xem
1158

Embedded microcomputer systems : real time interfacing

Nội dung xem thử

Mô tả chi tiết

Binary bits Bytes Alternatives

8 1 256

10 1024

12 4096

16 2 65536

20 1,048,576

24 3 16,777,216

30 1,073,741,824

32 4 4,294,967,296

n [[n/8]] 2n

Relationship between bits, bytes and alternatives as units of precision Common digital logic gates

Chip Function

‘00 2 input NAND

‘02 2 input NOR

‘04 Digital NOT

‘05 Open collector NOT

‘06 High voltage open collector NOT

‘07 High voltage open collector buffer

‘08 2 input AND

‘10 3 input NAND

‘11 3 input AND

‘14 Schmitt trigger NOT

‘20 4 input NAND

‘21 4 input AND

‘30 8 input NAND

‘32 2 input OR

‘125 4 tristate buffers

‘138 3 to 8 line decoder

‘139 2 to 4 line decoder

‘148 8 to 3 line encoder

‘163 4-bit counter

‘164 8-bit shift register

‘165 8-bit shift register

‘244 8 tristate buffers

‘245 8 bidirectional drivers

‘374 8 D flip-flops

‘573 8 transparent latches

‘589 8-bit shift register

‘595 8-bit shift register

‘676 16-bit shift register

Decimal digits Alternatives

3 1000

31

2 2000

31

4 4000

4 10000

41

2 20000

41

4 40000

5 100000

n 10n

Definition of decimal digits as a unit of precision

Data type Precision Range

unsigned char 8-bit unsigned 0 to 255

char 8-bit signed 128 to 127

unsigned int compiler-dependent

int compiler-dependent

unsigned short 16-bit unsigned 0 to 65535

short 16-bit signed 32768 to 32767

unsigned long unsigned 32-bit 0 to 4294967295L

long signed 32-bit 2147483648L to 2147483647L

float 32-bit float 10  38 to 1038

double 64-bit float 10  308 to 10308

Data types in C

48-pin 80-pin Shared Functions

PA0 PA7-PA0 Address/Data Bus

PB4 PB7-PB0 Address/Data Bus

PE7,4,1,0 PE7-PE0 IRQ, XIRQ, bus

— PJ7, PJ6 Key wakeup

PM5-PM0 PM5-PM0 SPI, CAN

PP5 PP7-PP0 PWM, key wakeup

PS1-PS0 PS3-PS0 SCI

PT7-PT0 PT7-PT0 Timer, PWM

PAD7-PAD0 PAD7-PAD0 ADC, Digital I/O

The 9S12C32 has nine external I/O ports

Pin Shared Functions

PAD15-PAD8 ADC

PAD7-PAD0 ADC

PA7-PA0 Address/Data bus

PB7-PB0 Address/Data bus

PE7-PE0 IRQ, XIRQ, bus

PH7-PH4 SPI2, key wakeup

PH3-PH0 SPI1, key wakeup

PJ7-6, PJ1-0 CAN4, I2

C, CAN0, key

PK7, PK5-PK0 Address bus

PM7-PM6 CAN3, CAN4

PM5-PM4 CAN2, CAN0, CAN4, SPI0

PM3-PM2 CAN1, CAN0, SPI0

PM1-PM0 CAN0, BDLC

PP7-PP4 PWM, SPI2, key wakeup

PP3-PP0 PWM, SPI1, key wakeup

PS7-PS4 SPI0

PS3-PS0 SCI1, SCI0

PT7-PT0 Timer

The 9S12DP512 has 91 I/O pins.

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Family Example VOL (V) IOL (A)

Standard TTL 7405 0.4 0.016

Schottky TTL 74S05 0.5 0.02

Low power Schottky TTL 74LS05 0.5 0.008

High speed CMOS 74HC05 0.33 0.004

High voltage output TTL 7406 0.7 0.040

High voltage output TTL 7407 0.7 0.04

Silicon monolithic IC 75492 0.9 0.25

Silicon monolithic IC 75451–75454 0.5 0.3

Darlington switch ULN-2074 1.4 1.25

MOSFET IRF-540 varies 28

Family Example VCE (V) ICE (A)

Silicon monolithic IC 75491 0.9 0.05

Darlington switch ULN-2074 1.4 1.25

MOSFET IRF-540 varies 28

Type NPN PNP Package Vbe(SAT) Vce(SAT) hfe min/max Ic

General purpose 2N3904 2N3906 TO-92 0.85 V 0.2 V 100 10 mA

General purpose PN2222 PN2907 TO-92 1.2 V 0.3 V 100 150 mA

General purpose 2N2222 2N2907 TO-18 1.2 V 0.3 V 100/300 150 mA

Power transistor TIP29A TIP30A TO-220 1.3 V 0.7 V 15/75 1 A

Power transistor TIP31A TIP32A TO-220 1.8 V 1.2 V 25/50 3 A

Power transistor TIP41A TIP42A TO-220 2.0 V 1.5 V 15/75 3 A

Power Darlington TIP120 TIP125 TO-220 2.4 V 2.0 V 1000 min 3 A

Output parameters for various open collector gates

Address Number Interrupt Source

$FFFE 0 Reset

$FFF8 3 Unimplemented Instruction Trap

$FFF6 4 SWI

$FFF4 5 XIRQ

$FFF2 6 IRQ

$FFF0 7 Real Time Interrupt, RTIF

$FFEE 8 Timer Channel 0, C0F

$FFEC 9 Timer Channel 1, C1F

$FFEA 10 Timer Channel 2, C2F

$FFE8 11 Timer Channel 3, C3F

$FFE6 12 Timer Channel 4, C4F

$FFE4 13 Timer Channel 5, C5F

$FFE2 14 Timer Channel 6, C6F

$FFE0 15 Timer Channel 7, C7F

$FFDE 16 Timer Overflow, TOF

$FFDC 17 Pulse Acc. Overflow, PAOVF

$FFDA 18 Pulse Acc. Input Edge, PAIF

$FFD8 19 SPI0, SPIF or SPTEF

$FFD6 20 SCI0, TDRE TC RDRF IDLE

$FFD4 21 SCI1, TDRE TC RDRF IDLE

$FFD2 22 ATD Sequence Complete, ASCIF

$FFCE 24 Key Wakeup J, PIFJ

$FFCC 25 Key Wakeup H, PIFH

$FFC0 31 I2C, IAAS TCF IBAL

$FFBE 32 SPI1, SPIF or SPTEF

$FFBC 33 SPI2, SPIF or SPTEF

$FFB2 38 CAN receive

$FFB0 39 CAN transmit

$FF8E 56 Key Wakeup P, PIFP[7:0]

9S12 interrupt vectors and CodeWarrior numbers

Output parameters for various open emitter gates

Chip Current Comment

MC3479 0.35 A Stepper driver

L293D 0.6 A Dual, diodes

L293 1 A Dual

TPIC0107 3 A Direction, fault status

L6203 5 A Dual

H-bridge drivers

Parameters of typical transistors used by microcomputer to source or sink current

General specification of various types of resistor components1

1 Wolf and Smith, Student Reference Manual, Prentice Hall, pg. 272, 1990.

Type Range Tolerance Temperature coef Max power

Carbon composition 1  to 22 M 5 to 20% 0.1%/°C 2 W

Wire-wound 1  to 100 k 0.0005% 0.0005%/°C 200 W

Metal film 0.1  to 1010  0.005% 0.0001%/°C 1 W

Carbon film 10  to 100 M 0.5% 0.05%/°C 2 W

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Embedded

Microcomputer Systems

Real Time Interfacing

Third Edition

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

This is an electronic version of the print textbook. Due to electronic rights restrictions, some third party content may

be suppressed. Editorial review has deemed that any suppressed content does not materially affect the overall

learning experience. The publisher reserves the right to remove content from this title at any time if subsequent rights

restrictions require it. For valuable information on pricing, previous editions, changes to current editions, and

alternate formats, please visit www.cengage.com/highered to search by ISBN#, author, title, or keyword for

materials in your areas of interest.

Embedded

Microcomputer Systems

Real Time Interfacing

Third Edition

Jonathan W. Valvano

University of Texas at Austin

Australia • Brazil • Japan • Korea • Mexico • Singapore • Spain • United Kingdom • United States

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Embedded Microcomputer Systems:

Real Time Interfacing, Third Edition

Jonathan W. Valvano

Publisher, Global Engineering:

Christopher M. Shortt

Acquisitions Editor: Swati Meherishi

Assistant Development Editor:

Yumnam Ojen Singh

Editorial Assistant: Tanya Altieri

Team Assistant: Carly Rizzo

Marketing Manager: Lauren Betsos

Media Editor: Chris Valentine

Content Project Manager: D. Jean Buttrom

Production Service: RPK Editorial Services, Inc.

Copyeditor: Shelly Gerger-Knechtl

Proofreader: Becky Taylor

Indexer: Shelly Gerger-Knechtl

Compositor: Glyph International Ltd.

Senior Art Director: Michelle Kunkler

Cover Designer: Andrew Adams

Cover Image: © Cybrain/Shutterstock

Internal Designer: Carmela Periera

Senior Rights Acquisitions Specialist:

Mardell Glinski-Schultz

Text and Image Permissions Researcher:

Kristiina Paul

First Print Buyer: Arethea L. Thomas

© 2011, 2007 Cengage Learning

ALL RIGHTS RESERVED. No part of this work covered by the copyright herein

may be reproduced, transmitted, stored, or used in any form or by any means

graphic, electronic, or mechanical, including but not limited to photocopying,

recording, scanning, digitizing, taping, web distribution, information networks,

or information storage and retrieval systems, except as permitted under

Section 107 or 108 of the 1976 United States Copyright Act, without the prior

written permission of the publisher.

For product information and technology assistance, contact us at

Cengage Learning Customer & Sales Support, 1-800-354-9706.

For permission to use material from this text or product,

submit all requests online at www.cengage.com/permissions.

Further permissions questions can be e-mailed to

[email protected].

Library of Congress Control Number: 2010938462

ISBN 13: 978-1-111-42625-5

ISBN-10: 1-111-42625-2

Cengage Learning

200 First Stamford Place, Suite 400

Stamford, CT 06902

USA

Cengage Learning is a leading provider of customized learning solutions with

office locations around the globe, including Singapore, the United Kingdom,

Australia, Mexico, Brazil, and Japan. Locate your local office at:

international.cengage.com/region.

Cengage Learning products are represented in Canada by Nelson Education, Ltd.

For your course and learning solutions, visit www.cengage.com/engineering.

Purchase any of our products at your local college store or at our preferred

online store www.cengagebrain.com.

Printed in the United States of America

1 2 3 4 5 6 7 14 13 12 11 10

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Embedded computer systems, which are electronic systems that include a microcomputer to

perform a specific dedicated application, are ubiquitous. Every week millions of tiny com￾puter chips come pouring out of factories like Freescale, Atmel, Maxim, Texas Instruments,

STMicroelectronics, Renesas, Microchip, Silicon Labs, and Mitsubishi and find their way into

our everyday products. Our global economy, food production, transportation system, military

defense, communication systems, and even quality of life depend on the efficiency and effec￾tiveness of these embedded systems. As electrical and computer engineers we play a major

role in all phases of this effort: planning, design, analysis, manufacturing, and marketing.

This book is unique in several ways. Like any good textbook, it strives to expose un￾derlying concepts that can be learned today and applied later in practice. The difference lies

in the details. You will find that this book is rich with detailed case studies that illustrate the

basic concepts. After all, engineers do not simply develop theories but rather continue all

the way to an actual device. During my years of teaching, I have found that the combination

of concepts and examples is an effective method of educating student engineers. Even as a

practicing engineer, I continue to study actual working examples whenever I am faced with

learning new concepts.

Also unique to this book is its simulator, called Test Execute and Simulate (TExaS).

This simulator, like all good applications, has an easy learning curve. It provides a self￾contained approach to writing and testing microcomputer hardware and software. It differs

from other simulators in two aspects. If enabled, the simulator shows you activity internal

to the chip, like the address/data bus, the instruction register, and the effective address

register. In this way the application is designed for the educational objectives of under￾standing how a computer works. On the other end of the spectrum, you have the ability to

connect such external hardware devices as switches, keyboards, LEDs, LCDs, serial port

devices, motors, and analog circuits. Logic probes, voltmeters, oscilloscopes, and logic an￾alyzers are used to observe the external hardware. The external devices together with the

microcomputer allow us to learn about embedded systems. The simulator supports many

of the I/O port functions of microcomputers like interrupts, serial port, output compare,

input capture, key wake up, timer overflow, and the ADC. You will find the simulator on

the CD that accompanies this book. Get the CD out now, run the Readme.htm, install

TExaS, and follow the tutorial example. In particular, double-click the tut.uc file in the

MC9S12 subdirectory and run the tutorial on the simulator. If you are still having fun, then

run the other four tutorials: tut2.* shows the simple serial I/O functions, tut3.* is an ADC

data acquisition example, tut4.* shows interrupting serial I/O functions, and tut5.* is an

interrupting square-wave generator. Although many programs are included in the appli￾cation, these five give a broad overview of the capabilities of the simulator. The screen shot

in Figure P.1 was obtained when running the tut2.rtf example. Notice these features in the

figure: (1) address/data bus activity, (2) embedded figures in the source code, (3) external

hardware, (4) voltmeters and logic probes, and (5) an oscilloscope.

v

Preface

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

P.1 General Objectives

This book constitutes an in-depth treatment of the design of embedded microcomputer sys￾tems. It includes the hardware aspects of interfacing, advanced software topics like inter￾rupts, and a systems approach to typical embedded applications. The book is unique to

other microcomputer books because of its in-depth treatment of both the software and hard￾ware issues important for real-time embedded applications. The specific objectives of the

book include the understanding of:

1. Advanced architecture

Timing diagrams

Memory and I/O device interfacing to the address/data bus

2. Interfacing external devices to the computer

Switches and keyboards

LED and LCD displays

vi Preface

Figure P.1 The TExaS simulator can be used to design, implement, and test embedded systems.

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

DC motors, servos, relays, and stepper motors

Amplifiers, analog filters, DAC, and ADC

Synchronous and asynchronous serial ports

Microphones, speakers, and thermostors

3. Advanced programming

Hardware/software synchronization

Debugging of real time embedded systems

Interrupts and real time events

Signal generation and timing measurements

Threads and semaphores

4. Embedded applications

Data acquisition systems with digital filters

Sound recording and playback

Linear and fuzzy logic control systems

Simple communication networks

P.2 Changes in the 3rd Edition

Removing the 6811 material has significantly improved how students can use this book.

Because the book focuses on just the 9S12, reading and using the book is very easy. In

other words, the organizational flow is much smoother than the 2nd Edition. Students can

read entire chapters because all parts apply to the 9S12. Conversely, students can pick and

choose individual sections about specific topics. Once a student has selected a topic, the

student can read the entire section, because the entire section is a complete well-contained

treatment of a particular topic.

One of the strengths of this book has been its wealth of practical examples. In the

3rd Edition, material is dearly separated into fundamental concepts and example designs.

In particular, each example design begins with a visual marker, followed by a concise but

clear problem specification. The solution is then developed in a logical top-down manner.

After the complete solution is presented and explained, another visual marker shows the

reader that the example has ended and the subsequent material is fundamental again. Many

new example designs are included.

There are 200 new homework exercises and 14 new labs. Exercises are divided into sim￾ple short answer and detailed design problems. Short answer questions are meant to rein￾force the reading. Design questions involve design, creativity, application, and integration

and are meant to be solved with paper and pencil. Lab assignments also involve design, cre￾ativity, application, and integration, but also include debugging and analysis.

There are many new topics added to the 3rd edition. The section on real time oper￾ating systems has more fundamentals and more examples. There is discussion on a design

and analysis of file systems for embedded systems. There is a section on how to use the flash

EEPROM for dynamic storage. The requirements document is described as an important

component of the design process. MOS circuit models are used to explain interfacing concepts.

There are many new sections on low power design, including regulators and battery chargers.

Transmission line theory is incorporated in the discussion of serial interfaces. The section

on flow charts is expanded to explain parallel and concurrent programming. There is a new

section on recursion. There are new debugging techniques. For example, there are many

figures of actual logic analyzer measurements to show students how the logic analyzer can

be used. There is a new section on theoretical aspects of modular programming. Synchro￾nization and interthread communication is presented in a formal way using semaphores,

mailboxes, and FIFO queues. Pseudo vectors are explained, along with the impact they have

on interrupt latency. There are new sections on time jitter, how to measure it, and how to re￾duce it. There is a new section on the physics of motor electromagnetics, and its implica￾tions on interfacing. There are new sections on brushless DC motors and servo motors.

Preface vii

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

viii Preface

There are sections on interfacing microphones and speakers. There are new audio labs. A

PWM DAC is presented. There are both fundamental theories and practical examples of

wireless communication for embedded systems. The DFT is presented and used for de￾signing FIR digital filters.

A number of sections have been moved to provide a more logical reading flow. The

LCD interface was moved from Chapter 8 to Chapter 3 because it is simple and matches

educational goals of Chapter 3. Tuning equations and timing diagrams were moved from

Chapter 9 into Chapter 3, because many schools skip chapter 9, but timing is an important

part of interfacing. EC was moved from Chapter 14 to Chapter 7, because I2C is like SPI

and used to interface the microcontroller to a peripheral. USB was moved from Chapter 14

to Chapter 7, because USB is like SCI and used to interface the microcontroller to the PC.

P.3 Prerequisites and Supplements

This book is intended for a junior- or senior-level course in microcomputer programming

and interfacing. We assume the student has knowledge of:

MC programming functions, variables, numbers, and contial structures

Basic digital logic (multiplexers, Karnaugh maps, tristate logic)

Data structures in C (queues, stacks, linked lists)

Test equipment like multimeters and oscilloscopes

Discrete analog electric circuits (resistors, capacitors, inductors, and transistors)

Although this book focuses on how to design embedded systems, extensive tutorials on the CD

help students with the important issues of how to program in assembly language and how to

program in C. A section later in this preface contains more information about what is on the CD.

To access all additional course materials for both instructors and students, please

visit www.cengagebrain.com. At the CengageBrain.com home page, search for the ISBN

of your title (from the back cover of your book) using the search box at the top of the page.

This will take you to the product page where these resources can be found.

P.4 Structure of the Book

We will use this font whenever displaying either assembly language or high-level code

written in C. For the most part, software that is encapsulated in a box has equivalent exam￾ples for assembly and C. The program number in the caption will assist you in finding the

software on the CD. All programs in an entire chapter are grouped together into one file.

For example, the assembly and C programs in Chapter 1 can be found on the CD as files

Chap1.asm and Chap1.c.

The C code in this book was written compiled and tested using the Metrowerks Code￾Warrior for the 9S12. We have been very successful transporting these software examples to

other compilers with only minor syntax modifications required. The major differences be￾tween the compilers are the syntax for embedded assembly and defining interrupt handlers;

we have tried using various free SmallC compilers, but the software in this book is too com￾plex to be compiled using SmallC. The biggest limitation of SmallC is its lack of support for

data structures. In other words, substantial editing would be required to use SmallC in a course

based on this book. Gnu C and Imagecraft ICC12 compilers are available for the 9S12.

We assume you have access to the Freescale programming reference guides for your par￾ticular microcomputer that show the details of each assembly instruction. You should also have

the microcomputer technical reference manuals, which detail the I/O ports you will be using.

For example, if you are using input capture to measure periods on the Freescale 9S12C32, you

will find basic principles and examples in this book, but you need to access the 9S12C32 Tech￾nical Summary for a complete list of all the details. In other words, you should to use this book

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

along with the manuals from Freescale. Although these reference manuals are available as pdf

documents on the CD, it might be better to order physical documents from Freescale’s liter￾ature center, or to download the latest version from the Freescale website.

Although software development is a critical aspect of embedded system design, this

book is not intended to serve as an introduction to C programming. Consequently, you will

find it convenient to have a C programming reference available. Fortunately, located on the

CD that accompanies this book, there is a small reference called Developing Embedded

Software in C using Metrowerks written as an HTML document. Although this reference is

not as complete a programming guide as some books on C, it is specific for writing em￾bedded software for the 9S12.

In this book we will discuss programming style, and develop debugging strategies spe￾cific to embedded real time systems from both an assembly language and a C perspective.

Due to the nature of single-chip computers (they are very slow and have very very little

RAM when compared to today’s desktop microcomputers) most of the available C compil￾ers for the single-chip microcomputers used in this book do not support objects, or float￾ing-point. Floating-point should be used only in situations where the range of values spans

many orders of magnitude or where the range of values is unknown at software design time.

Our experience is that numbers used in embedded systems usually have a narrow and

known range, so integer math is sufficient. On the other hand, there is some interest for ap￾plying object-oriented approaches of C to embedded system design. A few illustrations

of object-oriented design can be found in this book.

Chapters 1 and 2 can serve as an introduction to assembly language programming. Most

embedded systems engineers agree that a working knowledge of assembly is necessary even

when virtually all of our software is written in C. In specific, we believe we must know

enough assembly language to be able to follow the assembly listing files generated by our

compiler. This understanding of assembly language is vital when debugging, writing inter￾rupt handlers, calculating real time events, and considering reentrancy. Consequently, de￾tailed information on assembly language programming is included on the CD. In particular

you will find microcomputer data sheets, interactive on-line help as part of the TExaS sim￾ulator, and a short introduction to assembly language programming as an HTML document.

The electrical components used in this book span a wide range. Examples include

the 2764 PROM, 1N914 diode, 2N2222 transistor, 7406 open collector TTL driver,

74LS74 LSTTL flip flop, 74HC573 high speed CMOS transparent latch, Max494 op

amp, L293 interface driver, Hitachi 44780 LCD driver, IRF540 MOSFET, 6N139 opto￾coupler, Max232 driver, and Analog Devices DAC8043 digital-to-analog converters. It

is unrealistic for each student to have a personal library that contains the data books for

all these devices. On the other hand it is appropriate for the company or university to

establish a reference library that can be accessed by all the students. The circuit dia￾grams in this book usually include chip numbers and component values, but not pin

numbers or circuit board layout information. Consequently, with the appropriate data

sheets available, most circuits can be readily built.

P.5 How to Teach a Course Based on This Book

The first step in the design of any course is to create a list of educational objectives, along

with an understanding of the topics taught in previous classes and the topics needed as pre￾requisites to subsequent classes. Some important topics like computer architecture and

modular software design may be included in multiple courses. Armed with this list, the in￾structor (or department committee) searches for a book that covers most of the topics in an

effective manner. It is unrealistic to teach the entire contents of this book in a single

one-semester class, but the rationale in writing this book was to cover a wide range of pos￾sible classes. There are two approaches to selecting a subset of material from this book

to cover. The first approach is to pick a microcomputer and programming language. For

Preface ix

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

example, one could teach just assembly language or just C programming. In this situation,

one simply skips the other cases.

The other approach to selecting the appropriate subset is to pick and choose topics. For

example, a junior-level laboratory class might introduce the student to microcomputer in￾terfacing. This class might focus on interfacing techniques and may cover Chapters 1 to 4,

6 to 8 and a little bit of Chapters 11 to 13. For these students, the remaining parts of the

book become a resource to them for projects later in school or on the job. Another possi￾bility is a senior-level project laboratory class. The objectives of this class might focus on

the systems aspect of real time embedded systems. In this situation, some microcomputer

programming has been previously taught, so this course might cover the advanced inter￾facing techniques in Chapters 5, 9, 10, and 15 and the applications in Chapters 12 to 14. For

these students, the first half of the book becomes a review, allowing them to properly inte￾grate previously learned concepts to solve complex embedded system applications.

In most departments analog circuit design (for example, op amps and analog filters) is

taught in separate classes, so Chapter 11 will be a review chapter. Specific and detailed in￾formation about analog circuit design was included in this book to emphasize the system

integration issues when designing embedded systems. In other words, developing embed￾ded systems does not rely solely on the tools of computer and software engineering but

rather involves all of electrical, computer, and software engineering.

The next important decision to make is the organization of the student laboratory. As

engineering educators we appreciate the importance of practical “hands on” experiences in

the educational process. On the other hand, space, staff, and money constraints force all of

us to compromise, doing the best we can. Consequently, we present two laboratory possi￾bilities that range considerably in cost. Indeed, you may wish to mix two or more ap￾proaches into a hybrid simulated/physical laboratory configuration. We do believe that the

role of simulation is becoming increasingly important as the race for technological superi￾ority is run with shorter and shorter design cycle times. On the other hand, we should ex￾pose our students to all the phases of engineering design, including problem specification,

conceptualization, simulation, construction, and analysis.

In the first laboratory configuration, we use the traditional approach to an interfacing

laboratory. A physical microcomputer development board is made available for each labo￾ratory group of two students. There are numerous possibilities here. Companies such as

Technological Arts, Axiom, Wytec, and National Instruments produce development sys￾tems. In addition to the microcomputer board, each group will need a power supply, a pro￾totyping area to build external circuits, and the external I/O devices themselves. A number

of shared development/debugging stations will also have to be configured. It is on these

dedicated PC-compatible computers that the assembler or compiler is installed. If you de￾velop software in assembly, then the TExaS simulator can be used to edit, assemble, down￾load, and debug on a real 9S12 board. In most cases, when programming in C, a current

version of a C cross-compiler is greatly preferable. As mentioned earlier, the one possibil￾ity ImageCraft’s ICC12 (ImageCraft Inc. 2625 middlefield Rd. #685, Palo Alto, CA 94306

http://www.imagecraft.com). The Metrowerks CodeWarrior with educational license is also

an excellent choice for developing 9S12 software (Freescale, www.freescale.com). Test

equipment like an oscilloscope, a digital multimeter, and a signal generator are required at

each station. Expensive equipment like logic analyzers and printers can be shared. Some

mail-order companies sell used or surplus electronics that can be configured into laboratory

experiments (for possibilities, see my website http://users.ece.utexas.edu/~valvano). Many

laboratory assignments are available using this traditional configuration. For universities

that adopt this book, you will be allowed to download these assignments in Microsoft Word

format, then rewrite, print out, and distribute to your students laboratory assignments based

on these example laboratory assignments. Because of the detailed and specific nature of the

laboratory setup, rewriting will certainly be necessary. The 9S12C32 board from Techno￾logical Arts and the Metrowerks cross-compiler is the specific configuration presented in the

x Preface

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

example laboratory assignments, but the assignments are appropriate for most microcom￾puter development boards based on the 9S12.

The second laboratory configuration is based entirely on the TExaS simulator. Each

book comes with a CD that allows the student to install the application on a single computer.

Students, for the most part, work off campus and come to a teaching assistant station for help

or laboratory grading. In this configuration you can either develop software in assembly us￾ing the TExaS assembler or develop C programs using the free version of CodeWarrior. The

simulator itself becomes the platform on which the laboratory assignments are developed

and tested. The educational license of Metrowerks CodeWarrior supports code up to 32 K.

Laboratory assignments are also available using the simulator. Again, for universities that

adopt this book, you will be allowed to download these assignments in Microsoft Word for￾mat, then rewrite, print out, and distribute to your students laboratory assignments based on

these example laboratory assignments.

The exercises at the end of each chapter can be used to supplement the laboratory assign￾ments. In actuality, these exercises, for the most part, were collected from old quizzes and final

examinations. Consequently, these exercises address the fundamental educational objectives

of the chapter, without the overwhelming complexity of a regular laboratory assignment.

P.6 What’s on the CD?

The Readme.htm contains a few introductory tutorials about TExaS. These movies do not

need to be copied to your hard drive; you can simply watch the movies from the CD itself.

TExaS is a complete editor, assembler, and simulator for the 9S12 microcomputer. It sim￾ulates external hardware, I/O ports, interrupts, memory, and program execution. It is intended

as a learning tool for embedded systems. This software is not freeware, but the purchase of

the book entitles the owner to install one copy of the program. The Texas directory contains

the installer. You must install the software before using the application. Performing a typi￾cal installation, TExaS creates the following three subdirectories:

MC9S12 containing 9S12C32 assembly examples

MC9S12DP containing 9S12DP512 assembly examples

9S12C32 containing 9S12C32 CodeWarrior C examples

The Custom installation allows you to pick and choose among many choices. The sub￾directory ICC11 also contains the ImageCraft freeware compiler. You can run the existing

ICC12 examples, but to edit and recompile you will need the commercial C compiler. The

Metrowerks CodeWarrior or the Gnu GCC12 require separate installations.

The PDF directory contains many data sheets in Adobe pdf format. This information

does not need to be copied to your hard drive; you can simply read the data sheets from the

CD itself. In particular there are data sheets for microcomputers, digital logic, memory

chips, op amps, ADCs, DACs, timer chips, and interface chips.

The example directory contains software from the book. For example, all the assem￾bly language programs from Chapter 1 can be found in the file “Chap.1.asm.” Similarly,

all the C language programs from Chapter 1 can be found in the file “Chap1.c.”

The assmbly directory contains an HTML document describing how to program in as￾sembly for embedded systems using the TExaS application. This document does not need

to be copied to your hard drive; you can simply read the HTML document from the CD

itself. (Note also that the TExaS application itself contains a lot of information about as￾sembly language development as part of its on-line help).

The embed directory contains an HTML document describing how to program in C for

embedded systems. This document does not need to be copied to your hard drive; you can

simply read the HTML document from the CD itself.

The lab directory contains software that could be used in a laboratory setting.

Preface xi

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Tải ngay đi em, còn do dự, trời tối mất!