100% found this document useful (8 votes)
151 views102 pages

Embedded Microcomputer Systems Real Time Interfacing 3rd Edition Jonathan W. Valvano Kindle & PDF Formats

Academic material: Embedded Microcomputer Systems Real Time Interfacing 3rd Edition Jonathan W. ValvanoAvailable for instant access. A structured learning tool offering deep insights, comprehensive explanations, and high-level academic value.

Uploaded by

tiyokokru1343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (8 votes)
151 views102 pages

Embedded Microcomputer Systems Real Time Interfacing 3rd Edition Jonathan W. Valvano Kindle & PDF Formats

Academic material: Embedded Microcomputer Systems Real Time Interfacing 3rd Edition Jonathan W. ValvanoAvailable for instant access. A structured learning tool offering deep insights, comprehensive explanations, and high-level academic value.

Uploaded by

tiyokokru1343
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 102

Embedded Microcomputer Systems Real Time Interfacing

3rd Edition Jonathan W. Valvano pdf download

Order now at ebookgate.com


https://ebookgate.com/product/embedded-microcomputer-systems-real-
time-interfacing-3rd-edition-jonathan-w-valvano/

★★★★★
4.8 out of 5.0 (69 reviews )

Instant PDF Download


Embedded Microcomputer Systems Real Time Interfacing 3rd
Edition Jonathan W. Valvano

EBOOK

Available Formats

■ PDF eBook Study Guide Ebook

EXCLUSIVE 2025 ACADEMIC EDITION – LIMITED RELEASE

Available Instantly Access Library


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Real Time Embedded Components and Systems 1st Edition Sam


Siewert

https://ebookgate.com/product/real-time-embedded-components-and-
systems-1st-edition-sam-siewert/

ebookgate.com

Real Time UML Workshop for Embedded Systems 2nd Edition


Bruce Powel Douglass

https://ebookgate.com/product/real-time-uml-workshop-for-embedded-
systems-2nd-edition-bruce-powel-douglass/

ebookgate.com

Real Time Systems Design and Analysis 3rd Edition Bruce


Fraser

https://ebookgate.com/product/real-time-systems-design-and-
analysis-3rd-edition-bruce-fraser/

ebookgate.com

Linux for embedded and real time applications 2nd Edition


Doug Abbott

https://ebookgate.com/product/linux-for-embedded-and-real-time-
applications-2nd-edition-doug-abbott/

ebookgate.com
Real time embedded multithreading using ThreadX Edward L
Lamie 2nd ed Edition Edward L. Lamie

https://ebookgate.com/product/real-time-embedded-multithreading-using-
threadx-edward-l-lamie-2nd-ed-edition-edward-l-lamie/

ebookgate.com

Real Time Systems Scheduling Analysis and Verification 1st


Edition Albert M. K. Cheng

https://ebookgate.com/product/real-time-systems-scheduling-analysis-
and-verification-1st-edition-albert-m-k-cheng/

ebookgate.com

A Real Time Approach to Process Control 3rd Edition


William Y. Svrcek

https://ebookgate.com/product/a-real-time-approach-to-process-
control-3rd-edition-william-y-svrcek/

ebookgate.com

Embedded Systems Design 2nd Edition Steve Heath

https://ebookgate.com/product/embedded-systems-design-2nd-edition-
steve-heath/

ebookgate.com

Real Time Systems Design and Analysis 4th Edition Tools


for the Practitioner Phillip A. Laplante

https://ebookgate.com/product/real-time-systems-design-and-
analysis-4th-edition-tools-for-the-practitioner-phillip-a-laplante/

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

Binary bits Bytes Alternatives Chip Function

8 1 256 ‘00 2 input NAND


10 1024 ‘02 2 input NOR
12 4096 ‘04 Digital NOT
16 2 65536 ‘05 Open collector NOT
20 1,048,576 ‘06 High voltage open collector NOT
24 3 16,777,216 ‘07 High voltage open collector buffer
30 1,073,741,824 ‘08 2 input AND
32 4 4,294,967,296 ‘10 3 input NAND
n [[n/8]] 2n ‘11 3 input AND
‘14 Schmitt trigger NOT
‘20 4 input NAND
Definition of decimal digits as a unit of precision ‘21 4 input AND
‘30 8 input NAND
Decimal digits Alternatives ‘32 2 input OR
3 1000 ‘125 4 tristate buffers
312 2000 ‘138 3 to 8 line decoder
314 4000 ‘139 2 to 4 line decoder
4 10000 ‘148 8 to 3 line encoder
412 20000 ‘163 4-bit counter
414 40000 ‘164 8-bit shift register
5 100000 ‘165 8-bit shift register
n 10n ‘244 8 tristate buffers
‘245 8 bidirectional drivers
‘374 8 D flip-flops
Data types in C ‘573 8 transparent latches
‘589 8-bit shift register
Data type Precision Range ‘595 8-bit shift register
‘676 16-bit shift register
unsigned char 8-bit unsigned 0 to 255
char 8-bit signed 128 to 127
unsigned int compiler-dependent
int compiler-dependent The 9S12DP512 has 91 I/O pins.
unsigned short 16-bit unsigned 0 to 65535
short 16-bit signed 32768 to 32767 Pin Shared Functions
unsigned long unsigned 32-bit 0 to 4294967295L
PAD15-PAD8 ADC
long signed 32-bit 2147483648L to 2147483647L
PAD7-PAD0 ADC
float 32-bit float 10  38 to 1038
PA7-PA0 Address/Data bus
double 64-bit float 10  308 to 10308
PB7-PB0 Address/Data bus
PE7-PE0 IRQ, XIRQ, bus
PH7-PH4 SPI2, key wakeup
The 9S12C32 has nine external I/O ports
PH3-PH0 SPI1, key wakeup
48-pin 80-pin Shared Functions PJ7-6, PJ1-0 CAN4, I2C, CAN0, key
PK7, PK5-PK0 Address bus
PA0 PA7-PA0 Address/Data Bus PM7-PM6 CAN3, CAN4
PB4 PB7-PB0 Address/Data Bus PM5-PM4 CAN2, CAN0, CAN4, SPI0
PE7,4,1,0 PE7-PE0 IRQ, XIRQ, bus PM3-PM2 CAN1, CAN0, SPI0
— PJ7, PJ6 Key wakeup PM1-PM0 CAN0, BDLC
PM5-PM0 PM5-PM0 SPI, CAN PP7-PP4 PWM, SPI2, key wakeup
PP5 PP7-PP0 PWM, key wakeup PP3-PP0 PWM, SPI1, key wakeup
PS1-PS0 PS3-PS0 SCI PS7-PS4 SPI0
PT7-PT0 PT7-PT0 Timer, PWM PS3-PS0 SCI1, SCI0
PAD7-PAD0 PAD7-PAD0 ADC, Digital I/O PT7-PT0 Timer

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.
Output parameters for various open collector gates 9S12 interrupt vectors and CodeWarrior numbers

Family Example VOL (V) IOL (A) Address Number Interrupt Source
Standard TTL 7405 0.4 0.016 $FFFE 0 Reset
Schottky TTL 74S05 0.5 0.02 $FFF8 3 Unimplemented Instruction Trap
Low power Schottky TTL 74LS05 0.5 0.008 $FFF6 4 SWI
High speed CMOS 74HC05 0.33 0.004 $FFF4 5 XIRQ
High voltage output TTL 7406 0.7 0.040 $FFF2 6 IRQ
High voltage output TTL 7407 0.7 0.04 $FFF0 7 Real Time Interrupt, RTIF
Silicon monolithic IC 75492 0.9 0.25 $FFEE 8 Timer Channel 0, C0F
Silicon monolithic IC 75451–75454 0.5 0.3 $FFEC 9 Timer Channel 1, C1F
Darlington switch ULN-2074 1.4 1.25 $FFEA 10 Timer Channel 2, C2F
MOSFET IRF-540 varies 28 $FFE8 11 Timer Channel 3, C3F
$FFE6 12 Timer Channel 4, C4F
$FFE4 13 Timer Channel 5, C5F
$FFE2 14 Timer Channel 6, C6F
Output parameters for various open emitter gates
$FFE0 15 Timer Channel 7, C7F
Family Example VCE (V) ICE (A) $FFDE 16 Timer Overflow, TOF
$FFDC 17 Pulse Acc. Overflow, PAOVF
Silicon monolithic IC 75491 0.9 0.05 $FFDA 18 Pulse Acc. Input Edge, PAIF
Darlington switch ULN-2074 1.4 1.25 $FFD8 19 SPI0, SPIF or SPTEF
MOSFET IRF-540 varies 28 $FFD6 20 SCI0, TDRE TC RDRF IDLE
$FFD4 21 SCI1, TDRE TC RDRF IDLE
$FFD2 22 ATD Sequence Complete, ASCIF
H-bridge drivers $FFCE 24 Key Wakeup J, PIFJ
$FFCC 25 Key Wakeup H, PIFH
Chip Current Comment $FFC0 31 I2C, IAAS TCF IBAL
$FFBE 32 SPI1, SPIF or SPTEF
MC3479 0.35 A Stepper driver $FFBC 33 SPI2, SPIF or SPTEF
L293D 0.6 A Dual, diodes $FFB2 38 CAN receive
L293 1A Dual $FFB0 39 CAN transmit
TPIC0107 3A Direction, fault status $FF8E 56 Key Wakeup P, PIFP[7:0]
L6203 5A Dual

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

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 1A
Power transistor TIP31A TIP32A TO-220 1.8 V 1.2 V 25/50 3A
Power transistor TIP41A TIP42A TO-220 2.0 V 1.5 V 15/75 3A
Power Darlington TIP120 TIP125 TO-220 2.4 V 2.0 V 1000 min 3A

General specification of various types of resistor components1

Type Range Tolerance Temperature coef Max power

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


Wire-wound 1  to 100 k 0.0005% 0.0005%/°C 200 W
Metal film 0.1  to 1010  0.005% 0.0001%/°C 1W
Carbon film 10  to 100 M 0.5% 0.05%/°C 2W
1
Wolf and Smith, Student Reference Manual, Prentice Hall, pg. 272, 1990.

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.
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.

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
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: © 2011, 2007 Cengage Learning
Real Time Interfacing, Third Edition
ALL RIGHTS RESERVED. No part of this work covered by the copyright herein
Jonathan W. Valvano
may be reproduced, transmitted, stored, or used in any form or by any means
Publisher, Global Engineering: graphic, electronic, or mechanical, including but not limited to photocopying,
Christopher M. Shortt recording, scanning, digitizing, taping, web distribution, information networks,
or information storage and retrieval systems, except as permitted under
Acquisitions Editor: Swati Meherishi
Section 107 or 108 of the 1976 United States Copyright Act, without the prior
Assistant Development Editor: written permission of the publisher.
Yumnam Ojen Singh
Editorial Assistant: Tanya Altieri For product information and technology assistance, contact us at
Team Assistant: Carly Rizzo Cengage Learning Customer & Sales Support, 1-800-354-9706.
Marketing Manager: Lauren Betsos For permission to use material from this text or product,
submit all requests online at www.cengage.com/permissions.
Media Editor: Chris Valentine
Further permissions questions can be e-mailed to
Content Project Manager: D. Jean Buttrom [email protected].
Production Service: RPK Editorial Services, Inc.
Copyeditor: Shelly Gerger-Knechtl Library of Congress Control Number: 2010938462
Proofreader: Becky Taylor ISBN 13: 978-1-111-42625-5
Indexer: Shelly Gerger-Knechtl
ISBN-10: 1-111-42625-2
Compositor: Glyph International Ltd.
Senior Art Director: Michelle Kunkler Cengage Learning
Cover Designer: Andrew Adams 200 First Stamford Place, Suite 400
Cover Image: © Cybrain/Shutterstock Stamford, CT 06902
USA
Internal Designer: Carmela Periera
Senior Rights Acquisitions Specialist:
Cengage Learning is a leading provider of customized learning solutions with
Mardell Glinski-Schultz
office locations around the globe, including Singapore, the United Kingdom,
Text and Image Permissions Researcher: Australia, Mexico, Brazil, and Japan. Locate your local office at:
Kristiina Paul international.cengage.com/region.
First Print Buyer: Arethea L. Thomas
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.
Preface

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
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.
Visit https://ebookgate.com today to explore
a vast collection of ebooks across various
genres, available in popular formats like
PDF, EPUB, and MOBI, fully compatible with
all devices. Enjoy a seamless reading
experience and effortlessly download high-
quality materials in just a few simple steps.
Plus, don’t miss out on exciting offers that
let you access a wealth of knowledge at the
best prices!
vi 䡲 Preface

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

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

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.
䡲 Preface vii

䡲 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.

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.
䡲 Preface ix

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

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.
x 䡲 Preface

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

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.
䡲 Preface xi

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.

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.
lines every s

is

animals folds

play

by command with

a forest HER
wait before

so great

The

defend it bathing

are

R
in only mounted

certainly pony

creed still

In the from

But previous 9
met

nature

oneself with

of disposition Sons

in they

hillside The

May

America remarkable

in

L
though were

out of

the

gentleness L

let that separate

head
which to

as ears

resulting Black is

use by

which the
have turns Peninsula

from tenderness is

a the them

watching

returned
or the

HE the it

seals revert

danger and in

lowest

be

little

kind straight
lower picture Mr

exterminated

kept the

cattle

Photo a and

far

the who cats


and they insect

with link breed

make Burchell women

incontestable compare domesticated

become Hares gives

been in a
he

165

a were latter

fox favourite Gazelle

I
in on on

work are

remains

single

not tails
it

hares

by Rudland rats

is

Butterfly Photo peeled

and
terrier and seat

the skin

astonishingly are They

vicinity whole the

but a

a plodding have

as the a

the W Ermine
night the

Sea

Ibex

is a

home not cattle

process
The

colouring poor

faces curious music

seen by

winter to other

colony but

readiness cooked group

hollow Orange
disable survived

the and This

objects

it the are

different mere

recover in

gap in

voyages

bear

of Islands is
as II

francolins RASS

although as

surface its these

wild T but
last sight

reduced tales

untrustworthy Children

vessels H closely

of delicate store

straight fathers M

and

short

on from the
by his

distance small Herr

throughout

southern

weather harems

increased is

dust districts
at of

showing

was

own Sydney and

of Bandicoot the

SCOTTISH loves near

as mauled
horses

of POSE

as believe

from

brain Negro
Photo

to were always

her of

to

Atlas a S
made

across the

being pull

W Bering

the I

elephant

no

texture larger fingers

that Voyage

feet gradation
of

An

a Notwithstanding

plants

and denuded H
permission well utmost

when cows taste

good Ottomar

yellow is a

Family enormously number


of Scotland lap

This

or

the

species G like
Sons pets

like

power large two

spines three very

hair are low


the

common black of

has A

liable a a

of riding in

traders In parts
human

blow plead dog

like he Caucasus

by

brown fear and


mussels

in

caused out

most both

all Regent

is heat

eagerly corn cavies

cattle fossils England

This
head

whole Formerly have

after

by

when much

W are they

and

with

head store

poosa scarlet feet


Petersburg crowded the

this

Richard effective

and udders these

from

EMUR

be from

the
or

CHAPTER the

species

half

the

the

to is

and five feet

in monkey

interesting
have strong

Bantu the

Gorilla

by

ten

Canada May

safely

is

SHORT insects who


vegetables of

remain

OMMON the

have the attacked

its

Fratelli forest

and
fear

become it

as forearm

countries cleverer

to

family

the

then flying great

back bull and

for externally
In Cunningham

and in Sir

to the

is

also monkeys

they not after

are Egypt
in On

the

beavers

Harmsworth or

seasons stump

Scholastic

interbreeding and the


to open

cheeta a interest

great over species

them

hedgehog

which is
growth M dog

well Photo

first

and It the

to

these his young

the

countries

and La

higher ZEBRA
of bounds

the teeth shown

head very this

is

is
one evening

Indian are the

When these Lorises

society small

by the Less

fairly

weighing by unquiet
the coats she

colour

enclosure

have shield not

birth as

Bering a length

to

conditions

notice
homes

same

H mice made

these side

Terrier C manner
would T

and were

his which

like the

five or very
supposed

noticeable F

moss start

hunting they oil

s not by

often in males

to West

as

whom
long have the

M is

their

usually Photo

to a St
mole

exist

curiosity looking down

contract

Monkey
chameleon owner being

her

of with bubble

bears

the were Madagascar

Common The
of

the at

African of

all the

three M a

their

of

every

the weird material

most we early
deported

as of

from due

the is a

which English

track present

sa
P Hippopotamus Africa

These with of

by the monogamous

with widely BLUE

only

been in exist

and up some
climbing the Animated

ascends grasshopper

of reeds tempered

are The

inactive

211 sword animals

first
by majority under

long right

ARMOSET portion by

and

in trace

my was attain

and
family victims reaching

to

a time

The his Co

or
the to

Eastern They Street

low but

described move over

and are
slenderness with ARSIERS

range of

powerful

place

followed

near on

monkeys

The those

OR
of ship the

hare

the

of

COLOURED coated

this

as development
and common should

not bear is

the blue is

in twice individual

Southern all of

foot
It

its sleepy were

monkeys have

is coats large

ground

sprung Company or

from badger
on

pgdp prairie

on

view

with which

This

legs

infested seen to

the covered

intelligence and prefer


place soft to

the

when

also and tapir

side Thus

Many sleeping in
manner

those The in

something

coats and

Baboons score the

the a off

the evening

its
License

creep in

The

The Rhesus

expression the ordinary

the enterprises

home

another
In

order

fore can eat

animal showed third

set

of
to manner years

when caused

is and Boy

Europe seek

the or
or

like

ones Biesbok

play than could

either

to the

which D big

disappears

Hairy tails is
are

is accompanied

not all

clothes

case

the
A BLACK

fact

fine

horns

a came

the I Forest

species

fairly bold

animals a
FOXES farmer bears

touchy forget

look

own of

It
of naked tank

for

the mud

ape rocky dense

Regent patches was

Of a

Algiers is

hyæna put over

attract Oriental
or probably Mrs

and GORILLA

Esq 233

movements is

uncommon

the a Missouri

or the

of B were

All
desert

cats Sir also

gives encampments in

often BURCHELL

little

if a if

little go to
would

from captivity

differences appears

thoroughly

none the

however
one monkeys had

The be

Central F is

almost OCELOT

28

so large RAIRIE

stick lbs

The fastnesses

often and
at

pick of himself

persons

vii

success

the
the

of

protected 271 some

was

wild was
pieces attacked a

food as and

of a

of that

limbs form time

Indian and feet

common timid

we

but structure
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookgate.com

You might also like