Cover image for Microcomputer engineering
Title:
Microcomputer engineering
Author:
Miller, Gene H.
Personal Author:
Edition:
Second edition.
Publication Information:
Upper Saddle River, N.J. : Prentice Hall, [1999]

©1999
Physical Description:
xx, 539 pages : illustrations ; 25 cm
General Note:
Includes index.
Language:
English
ISBN:
9780138953683
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Central Library TK7888.3 .M548 1999 Adult Non-Fiction Non-Fiction Area
Searching...

On Order

Summary

Summary

A complete textbook and laboratory/homework manual for sophomore/junior-level courses in Microcomputers. This text focuses on microcomputers and microprocessors used as control devices (e.g., the Motorola 68HC11). Extensive material on using the Motorola M6HC11EVB and M68HC11EBU Trainers.


Excerpts

Excerpts

To the Student Microcomputer Engineering, Third Edition, was written for students studying engineering and related disciplines in a first microcomputers course. Knowledge of microprocessors and single-chip microcomputers is essential to the design of products, manufacturing equipment, and laboratory instrumentation. Many schools now require at least one microcomputers course that includes laboratory work with these devices. Practicing engineers with some digital systems background can learn this material without an instructor by using this book. The best background includes courses in electrical circuits, electronics, digital systems, and high-level language programming. Digital systems is the most important of these. This textbook will help you learn the fundamentals of microcomputers; it is not a computer manual. Examples demonstrate conceptual topics, since most people learn examples before they can generalize. Small sections cover only a few details at a time. I introduce the computer instructions only when the topic requires them; a table of the instructions appears only in an appendix. You should experience the computer by hands-on work with microcomputer training hardware. In using such hardware, you will see all its features simultaneously, and that is a problem. You cannot force parts of the hardware to stop operating until you learn about them; the hardware operates whether you know about it or not. You must learn to ignore those things that you are not yet prepared to comprehend. Similarly, in this book, unnecessary details are ignored until you are ready for them. Implement all the small program examples on trainer hardware as you read for the best learning experience. I recommend the Motorola M68HCIIEVB or M68HC11EVBU2 microcomputer trainers for implementing the examples and exercises. Additional reference material is available through the Internet on the World Wide Web at WWW.PRENHALL.COM. I sincerely hope that this book will be useful to students. If the opportunity arises, I will improve it based upon the recommendations and other feedback that I receive. I invite and urge you to write to me to comment on this book; student opinion about books is hardly ever heard, but always appreciated. To the Instructor Microcomputer Engineering is a complete course-teaching aid that encourages hands-on laboratory work. The exercises in this third edition have been greatly expanded and improved. An associated website at WWW.PRENHALL.COM supports the text material. The Motorola 68HCII single-chip microcomputer/microprocessor is the only hardware discussed. I recommend the Motorola M68HC 11EVB or the M68HC 11EVBU2 microcomputer trainer with a personal computer system running Microsoft®Windows NT®or its successors for laboratory work. Considering the low cost of microcomputer trainers, I prefer them over software simulators. All the example programs and exercises can be run on the recommended trainers. I also recommend the PFE freeware editor and the 2500AD assembler. Material related to this support equipment and software is provided on the Web site. Other equipment and software can be used, although with greater effort. The aforementioned Web site also describes how to set up a complete laboratory. The text makes teaching easy. The order of the chapters is the order in which I present the material. I want students working on a trainer as soon as possible, so I deliberately simplified the early topics. Reading assigned by section is possible since the sections are mostly independent of one another. Small laboratory/homework exercises are at the end of each chapter. Larger projects are on the Web site. Chapter 1 reviews the digital systems and computer fundamentals required. The section on number systems is essential to understanding later chapters. Chapter 2 introduces some of the microprocessor registers, the programming model, and the functions of these registers. Following this, some instructions and the addressing modes are introduced with straightforward examples. At the end of this chapter, a section discusses designing and writing a small machine language program. I encourage laboratory/homework exercises on the trainer that demonstrate the instruction set, addressing modes, and a machine language program. Chapter 3 changes direction and introduces assembly language. All examples thereafter use assembly language. Motorola notation and terminology are used so you can reference Motorola manuals without confusion. Anything in program examples specifically related to the particular assembler program used for their development has been removed. Exercises in writing simple programs using an editor and assembler are appropriate, but only use the instructions from Chapter 2 at this point. The student is now beginning to understand what a microcomputer is and how to program it. Because bad habits develop quickly, discussing program design before people have much programming experience is important. Chapter 4 concentrates on the established ideas for writing cost-effective and useful programs. Most microcomputer book authors avoid this topic apparently assuming that good software engineering is unnecessary; this author assumes exactly the contrary. Chapter 5 introduces most of the remaining instructions using assembly language. Instructions are grouped according to their usual function, such as bit manipulation, comparison, BCD arithmetic, and stack operations. Subroutines and several parameter-passing techniques are covered in detail. Chapter 6 covers hardware, input/output concepts, and input/output programming. Microprocessor buses, memory and 1/O chips, and input/output synchronization techniques are the main topics. Little electronics knowledge is required. The I/O section includes both polling and interrupt techniques. The interrupt material is quite extensive, including discussion of concurrency and reentrancy problems and their solutions. Chapter 7 covers the I/O hardware capabilities of the 68HC 11 chip. Operation in both the single-chip microcomputer and expanded modes, chip versions, chip configuration, and pin connections are first. The next topics include hardware reset and details of the interrupt system. The I/O hardware sections that follow discuss the real-time clock, programmable timer, pulse accumulator, serial communications interface, and the analog-to-digital converter--all with programming examples. The next section on fail-safe operation discusses the COP timer, clock failure detection, and illegal instruction response. The hardware expansion section covers microprocessor bus extension, the SPI bus, and the port replacement unit. Finally, special hardware operations, such as stopping the clock, are covered. Chapter 8 introduces the concept of an operating system and discusses the principles of real-time systems and multitasking systems. Chapter 9 contains a major design example that encompasses much of the material in the first eight chapters. The goal is to develop a working product based on a relatively simple real-time multitasking operating system with preemptive priority scheduling. The product is a basic weather station that displays wind speed and direction on both digital displays and on a CRT. Design specifications for the weather station are stated first, then the complete operating system software is presented and discussed. Finally, all the tasks required to meet the weather station specifications are presented and discussed. The simplest working approach to the software is chosen in all cases. While reading the discussion of the software in this chapter, also "read the code." Chapter 9 provides all the program code to make a working weather station. The required laboratory hardware is common to most student labs. The anemometer and wind vane are easily simulated with simple electronics if necessary. Developing realistic student projects is often difficult because of the time required for students to get started. The design project in Chapter 9 provides a significant foundation for building additional projects. The projects can be modifications and improvements to the operating system, additions to the weather station, or development of entirely new applications of the operating system. In all these cases, the complexity is great enough to challenge students without requiring many hours of preliminary work. The modular nature of the multitasking operating system encourages student teamwork. Appendix A documents the 68HC 11 instruction set with an instruction set table, a reverse instruction set table, and op code maps. Appendix B tabulates the internal 68HCI 1A8 1/O hardware control registers. Appendix C has been expanded to include information about the M68HC 11EVB, M68HC 11EVBU, and M68HCI 1EVBU2 trainers and includes a tutorial on their use. The presentation should minimize any confusion about the differing features of the three trainers. Appendix C is particularly useful to the student doing hands-on projects in a laboratory using a Motorola trainer. Appendix D contains answers to selected exercises. See the associated Web site for additional material, such as documentation on other microcomputer trainers, the PFE editor program, and assembler programs; lab setup information; source code for some examples; and laboratory exercises. A glossary of terms used in the text is also available. Excerpted from Microcomputer Engineering by Gene H. Miller All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Table of Contents

Prefacep. xvii
Chapter 1 Computer Fundamentalsp. 1
1.1 Numbers and Number Systemsp. 2
Octal, Hexadecimal, and Binary Numbersp. 2
Two's Complement Signed Numbersp. 5
Binary-coded Decimal Numbersp. 10
1.2 Digital System Fundamentalsp. 11
Signals, Functions, and Hardwarep. 11
Combinational Logic Networksp. 16
Flip Flops and Registersp. 18
Memoryp. 21
Synchronous Sequential Networksp. 23
1.3 Digital Systemsp. 26
Synchronous Serial Communications Examplep. 26
Instruction-controlled Information Processor Examplep. 28
1.4 Stored Program Processorsp. 33
Block Diagramp. 33
Instruction Operationp. 37
Definition of the Instruction Setp. 38
General-purpose Computerp. 38
1.5 Microprocessors and Microcomputersp. 40
Integrated Circuit Technologyp. 40
The Microprocessor and Microcomputerp. 41
Microcomputer Applicationsp. 43
1.6 Reviewp. 45
1.7 Exercisesp. 45
Chapter 2 Instruction Subset and Machine Languagep. 49
2.1 The 68HC11 Computer Operationp. 50
The Programming Modelp. 50
Internal Computer Operationsp. 53
2.2 Instructions and Addressing Modesp. 66
Extended Addressingp. 66
Direct Addressingp. 68
Inherent Addressingp. 70
Double-byte Datap. 71
Immediate Addressingp. 73
Indexed Addressingp. 75
Relative Addressingp. 77
2.3 Addressing Mode Summaryp. 84
2.4 An Expanded Repertoirep. 86
The Instruction Set Tablep. 86
A Tour through the Basic Instructionsp. 88
The Comparison Branch Instructionsp. 93
Applications of Complex Instructionsp. 96
Double-precision Instructionsp. 98
2.5 Machine Language Programming Examplep. 99
Minimum Requirements of a Good Programp. 99
A Classic Example: Copy a Tablep. 100
2.6 Reviewp. 109
2.7 Exercisesp. 109
Chapter 3 Assemblers and Assembly Languagep. 115
3.1 The Assembly Processp. 116
The Editor, Assembler, and Loader Programsp. 116
The Source Module, Load Module, and Listingp. 119
3.2 The Motorola Assembly Languagep. 121
Source Statement Contentp. 122
Source Statement Formatp. 124
The Basic Assembler Directivesp. 126
3.3 Examples from the Assemblerp. 130
Some Good Assembly Languagep. 130
Some Bad Assembly Languagep. 137
Assembly Language to Copy a Tablep. 141
3.4 Reviewp. 145
3.5 Exercisesp. 145
Chapter 4 Program Structure and Designp. 151
4.1 The Hard Cold Factsp. 152
What Does Software Cost?p. 152
What about Software Quality?p. 152
Programming Is Hard Workp. 153
Starting on the Right Pathp. 153
4.2 Program Design-What's Importantp. 154
Programmers' Goalsp. 154
What We Are Working Withp. 155
Assessing the Goals Based on Realityp. 156
4.3 Practical Programmingp. 158
4.4 Flowchartingp. 159
Flowchart Symbolsp. 159
Flowchart Examplep. 161
4.5 Structured Programmingp. 162
Fundamental Program Structuresp. 163
Extended Program Structuresp. 166
Identifying Structured and Unstructured Programsp. 168
Making Structured Loopsp. 169
A Troublesome Casep. 170
Will You Use It?p. 172
Making Unstructured Programs Structuredp. 173
4.6 Top/Down Designp. 173
Choosing Program Modulesp. 174
Top/Down Design Using Flowchartsp. 174
Top/Down Design Summaryp. 176
4.7 Structured Top/Down Assembly Languagep. 177
A Good Programp. 177
A Bad Programp. 181
4.8 Large-Scale Top/Down Designp. 184
The Top/Down Teamp. 185
Top/Down Implementationp. 185
4.9 Small-Scale Top/Down Designp. 188
4.10 Reviewp. 188
4.11 Exercisesp. 188
Chapter 5 Advanced Assembly Language Programmingp. 193
5.1 More Indexingp. 193
Consequences of a Large Instruction Setp. 194
Op Code Mapsp. 194
Index Register Exchange Instructionsp. 195
Another Instruction for Dp. 195
5.2 Bit and Byte Manipulationp. 195
Shift Operationsp. 195
Logical Operationsp. 198
5.3 Arithmetic Operationsp. 206
Multiplicationp. 206
Divisionp. 208
BCD Operationsp. 208
5.4 The Stackp. 209
Stack Operationp. 209
Stack Hardwarep. 210
Stack Instructionsp. 211
Stack Examplep. 212
Using the Stackp. 214
5.5 Subroutinesp. 215
Subroutine Conceptsp. 215
Instructions for Writing Subroutinesp. 215
The First Subroutine Examplep. 217
Flowcharting Subroutinesp. 218
Parameter Passingp. 219
An Example of a Bad Subroutinep. 220
Some Basic Subroutine Design Considerationsp. 222
5.6 Subroutine Parameter Passing Techniquesp. 223
Call-by-Value Techniquep. 223
Call-by-Reference Techniquep. 230
5.7 Recursive Subroutinesp. 242
5.8 Reviewp. 243
5.9 Exercisesp. 243
Chapter 6 Hardwarep. 249
6.1 Hardware/Software Synergyp. 250
6.2 The Hardware Building Blocksp. 250
Microcomputerp. 250
Memoryp. 251
Microprocessorp. 252
Busesp. 252
I/O Integrated Circuitsp. 252
6.3 Memory Characteristicsp. 252
Memory Terminologyp. 253
Memory Principlesp. 254
Read Only Memory ICsp. 257
Read/Write Memory ICsp. 260
Matching Software to Memoryp. 260
6.4 Microprocessor Busesp. 261
Bus Characteristicsp. 261
Microprocessor Bus Connectionsp. 262
Bus Operation Examplep. 264
Computer Failuresp. 266
Memory Expansionp. 268
6.5 Parallel I/O Principlesp. 269
I/O Programming Modelp. 270
6.6 Parallel I/O Hardwarep. 271
I/O Circuit Constructionp. 273
Programmable I/O Hardwarep. 278
6.7 68HC11 Parallel I/O Hardwarep. 278
The PORTB Registerp. 279
The PORTC Registerp. 279
The DDRC Registerp. 280
The PIOC and PORTCL Registersp. 280
6.8 Parallel I/O Example Using Pollingp. 281
Problem Descriptionp. 281
I/O Hardwarep. 281
Polling Softwarep. 282
6.9 Interrupt Conceptsp. 284
6.10 The 68HC11 Interrupt Systemp. 284
Interrupt Signal Pathp. 285
Interrupt System Operationp. 286
6.11 IRQ Interrupt Examplesp. 288
Single Interrupting Devicep. 288
Multiple Interrupting Devicesp. 291
6.12 The Concurrency Problemp. 298
How It Happensp. 299
Preventing Problemsp. 299
Example Program with Concurrency Problemp. 301
6.13 The Reentrancy Problemp. 303
The Data Corruption Problemp. 304
Data Corruption Solutionsp. 307
More Examples of Reentrant Subroutinesp. 309
6.14 Troubleshooting Concurrency and Reentrancy Problemsp. 310
What You Are Up Againstp. 310
Don't Be Misledp. 310
Do It Right the First Timep. 310
6.15 Reviewp. 311
6.16 Exercisesp. 311
Chapter 7 Advanced 68HC11 Hardwarep. 321
7.1 The Hardware Configurationp. 321
Operating Modesp. 322
The 68HC11 Chip Versionsp. 322
Block Diagram of the 68HC11p. 322
68HC11 Pin Connectionsp. 325
7.2 Memory Spacep. 325
7.3 Hardware Resetp. 328
Reset Operationp. 328
Hardware Programmable Optionsp. 329
Timed-Write-Once Programmable Optionsp. 329
7.4 Interrupt Systemp. 330
IRQ Interruptp. 330
Software Interruptp. 332
XIRQ Interruptp. 332
Illegal Instruction Interruptp. 333
Interrupt Priorityp. 334
7.5 Parallel I/O Portsp. 334
Hardware Initializationp. 335
Parallel I/Op. 335
7.6 Internal Flagsp. 337
The STAF Flagp. 337
Direct-Clearing Flagsp. 337
7.7 Real-Time Clockp. 338
The RTI Devicep. 338
RTI Programming Examplep. 339
7.8 The Programmable Timerp. 342
Timer Principlesp. 342
Free-Running Counterp. 344
Input Capturep. 345
Output Comparep. 352
Using Input Capture with Output Comparep. 362
Timer Flag Applicationsp. 366
7.9 Pulse Accumulatorp. 366
Event-Counting Modep. 367
Gated-Time-Accumulation Modep. 370
Pulse-Accumulator Flag Applicationsp. 375
7.10 Serial Communications Interfacep. 375
Data Transmissionp. 376
Communication Terminologyp. 377
ASCII Communication Codesp. 379
Serial Communication Principlesp. 380
SCI Serial I/O Hardwarep. 387
Programming the SCIp. 394
SCI Programming Examplep. 396
7.11 Analog-to-Digital Converterp. 401
Analog-to-Digital Conversion Principlesp. 401
68HC11 A/D Converterp. 402
Analog Input Examplep. 406
7.12 Fail-Safe Operationp. 409
Watchdog Timerp. 409
Clock Failure Detectionp. 412
7.13 I/O Port Summaryp. 413
Port A

p. 413

Port B

p. 413

Port C

p. 413

Port D

p. 414

Port E

p. 414

7.14 Hardware Expansionp. 414
Serial Peripheral Interfacep. 414
Microprocessor Bus Expansionp. 418
7.15 Special Hardware Operationp. 421
Highest-Priority Interruptp. 421
Wait Modep. 421
Stop Modep. 422
Factory Testsp. 423
7.16 Reviewp. 423
7.17 Exercisesp. 423
Chapter 8 Real-time Operating Systemsp. 429
8.1 System Characteristicsp. 430
Real-time Systemsp. 430
Multitasking Systemsp. 431
8.2 Operating System Structurep. 432
System Tablesp. 432
System Softwarep. 432
System Clockp. 433
8.3 Tasks and Their Controlp. 434
Task Statep. 434
Multitaskingp. 435
Task Switchingp. 439
8.4 Operating System Servicesp. 441
8.5 Reviewp. 443
8.6 Exercisesp. 443
Chapter 9 Real-time System Designp. 445
9.1 Weather Station Designp. 446
Weather Station Specificationsp. 446
Weather Station Hardwarep. 447
9.2 Operating System Designp. 450
Multitaskingp. 450
System Clockp. 450
I/O Supportp. 451
9.3 Operating System Implementationp. 451
Task-Control-Blocksp. 452
System Startupp. 454
The Background Taskp. 454
System Service Callsp. 457
Schedule Task with an Interruptp. 461
The Dispatcherp. 463
The Suspend Servicep. 464
The System Clockp. 465
The Schedule Servicep. 467
The SCI Transmit/Receive Servicesp. 470
System Performance Indicatorsp. 476
9.4 Weather Station Implementationp. 479
Task Variablesp. 479
Task0--Wind Speedp. 479
Task5--Zero Wind Speedp. 483
Task1--Wind Directionp. 485
Task3--Wind Direction Messagep. 487
Task2--Wind Speed Message on CRTp. 489
Task4--Wind Speed Digital Displaysp. 492
Task6--Reset Highest Wind Speed and Flash Lightp. 494
Final Detailsp. 495
9.5 Reviewp. 496
9.6 Exercisesp. 497
Appendix A The 68HC11 Instruction Setp. 501
A.1 Instruction Set Table and Programming Modelp. 502
Motorola 68HC11 Programming Modelp. 504
Motorola 68HC11 Instruction Setp. 505
A.2 Reverse Instruction Set Tablep. 512
A.3 The 68HC11 Op Code Mapsp. 514
Appendix B Hardware Control Registersp. 517
B.1 Register Addressesp. 517
B.2 Control Registers and Bitsp. 518
Appendix C The Motorola M68HC11EVB, EVBU, and EVBU2 Microcomputer Trainersp. 521
C.1 Introduction to the Motorola Trainersp. 522
The Trainer Componentsp. 522
CRT Terminalp. 522
Monitor Programp. 522
Trainer Startupp. 523
Monitor Program Crashesp. 523
C.2 Monitor Program Featuresp. 523

Google Preview