桂林电子科技大学毕业设计(论文)专用纸 第 1 页 共26页
Preface
During the early years of microprocessors, there were few engineers witheducation and experience in the applications of microprocessor technology.Now that microprocessors and microcontrollers have become pervasive in somany devices, the ability to use them has become almost a requirement formany technical people.
Today the microprocessor and the microcontroller have become two of themost powerful tools available to the scientist and engineer. Microcontrollershave been embedded in so many products that it is easy to overlook the factthat they greatly outnumber personal computers. Millions of PCs are shippedeach year, but billions of microcontrollers ship annually. While a great deal ofattention is given to personal computers, the vast majority of new designs arefor embedded applications. For every PC designer, there are thousands ofdesigners using microcontrollers in embedded applications. The number ofembedded designs is growing quickly. The purpose of this book is to give thereader the basic design and analysis skills to design reliable microcontroller ormicroprocessor based systems. The emphasis in this book is on the practicalaspects of interfacing the processor to memory and I/O devices, and the basicsof interfacing such a device to the outside world.
A major goal of this book is to show how to make devices that are inherentlyreliable by design. While a lot of attention has been given to “quality improve-ment,” the majority of the emphasis has been placed on the processes thatoccur after the design of a product is complete. Design deficiencies are a sig-nificant problem, and can be exceedingly difficult to identify in the field.These types of quality problems can be addressed in the design phase withrelatively little effort, and with far less expense than will be incurred later inthe process. Unfortunately, there are many hardware designers and organiza-tions that, for various reasons, do not understand the significance and ex-pense of an unreliable design. The design methodology presented in this textis intended to address this problem. Learning to design and develop a microcontroller system without any practicalhands-on experience is a bit like trying to learn to ride a bike from readingbook. Thus, another goal is to provide a practical example of a completeworking product. What appears easy on paper may prove extremely difficultwithout some real world experience and some potentia
桂林电子科技大学毕业设计(论文)专用纸 第 2 页 共26页
lly painful crashes.
In order to do it right, it’s best to examine and use a real design. On the otherhand, the current state of the technology (surface mounted packaging, etc.)can make the practical side problematic. In order to address this problem, aspecial educational System Development Kit is available to accompany thisbook (8031SDK). All the documentation to construct an SDK is availableon the companion CD-ROM. This info, along with updated informationand application examples, is also available on the web site for this book:http://www.hte.com/echdbook. All the information needed to build the SDKis available there, as well as information on how to order the SDK assembled and tested.
While searching for an appropriate text for one of the courses I teach inembedded computer engineering, I was unable to locate a book that coveredthe topic adequately. An earlier version of this book was written to accom-pany that course and has since evolved into what you see here. The courseis offered at the University of California, San Diego Extended Studies, andis titled “Embedded Controller Hardware Design.” The same courses mayalso be taken in an on-line format using the Internet, and can be found athttp://www.hte.com/uconline/ecd The goals of the course and the book arevery much the same: to describe the right way to design embedded systems.
While no prior knowledge of microcontrollers or microprocessors is required,the reader should already be familiar with basic electronics, logic, and basiccomputer organization. Chapter one is intended as a review of those basicconcepts. Next there is a general overview of microcontroller architecture,and a specific microcontroller chip architecture, the 8051 family, is introducedand detailed. The 8051 was chosen because it can be interfaced to externalmemory, has simple timing specs, is widely used and available from a numberof manufacturers. The concepts of worst-case design and analysis are describedalong with techniques for hardware interfacing. A good embedded designrequires familiarity with the underlying memory technology, including ROM,SRAM, EPROM, Flash EPROM, EEPROM storage mechanisms and devices.The processor bus interface is then covered in general form, along with anintroduction to the 8051’s bus interface. Most embedded designs can alsobe
桂林电子科技大学毕业设计(论文)专用纸 第 3 页 共26页
nefit from the use of user programmable logic devices (PLD). This subjectis too complex for in-depth coverage here, so PLD technology is covered froma relatively high level. The central theme of designing an embedded systemthat can be proven to be reliable is illustrated with a simple embedded con-troller. The iterative nature of the design process is shown by example, andseveral design alternatives are evaluated. With the central part of the designcompleted, the remaining chapters cover the various types of I/O interfaces,bus operations, and a collection of information that is seldom included in theusual sources, but is often handed down from one engineer to another.
I hope that you will find this book to be useful, and welcome any observationsand contributions you may have. If you should find any errors in the text, or ifyou know of some good embedded design resources, please feel free to contactme directly by e-mail: ken.arnold@ieee.org CHAPTER ONE
Review of ElectronicsFundamentals
Why are microprocessors and microcontrollers designed into so many differentdevices? While there are many dry and practical reasons, I suspect one of thestrongest motivations for using a microprocessor is simply that it is a lot more fun.Over the past few decades of the so-called “computer revolution,” I have seenmany products and projects that could have been handled without resortingto a microprocessor. Yet there is always a tendency to rationalize the choice ofa micro-based solution by economic or technical arguments to support thedecision. In fact, most of the really excellent products were successful to a greatextent because they were fun to develop. Many of the best product ideas haveoccurred when someone was “playing” with something they were interestedin. In my own experience, I have found learning something new is mucheasier and more effective when I am “just playing around” rather than tryingto learn in a structured way or against a deadline. Studies of various educa-tional methods also indicate “coached exploration” is more effective than thetraditional methods. These and other observations lead me to the conclusionthat the best way to learn about a microcontroller is by “playing” with one.
No book—no matter how well written—can possibly motivate and educateyou as well as
桂林电子科技大学毕业设计(论文)专用纸 第 4 页 共26页
building and playing with a microcontroller. The best way tolearn the concepts in this book is to build a simple microcontroller. Even if itis capable of nothing more than blinking a light, it will provide a concreteexample of the microcontroller as a tool that can be fun to use. To ease thiseffort, a companion system development kit (SDK), is available to accompanythis text. It incorporates the functions of a stand-alone single board computer(SBC), and an in-circuit emulator (ICE). It also serves as a sample embeddedcontroller design. The design is included on the CD-ROM and web site forthis book, so anyone can reproduce and use it as a learning tool. By applying the guidelines set forth in this book to real world hardware, you can learnto design reliable embedded hardware into other products. Information onobtaining the SDK can be found in the Preface. Objectives
Several different skills are required for successful embedded hardware design.Here are some of the things you will know how to do when you finish this book: * Interpret design requirements for the design of an embedded controller. * Read and understand the manufacturer’s specification sheet. * Select appropriate ICs for the design.
* Interface the CPU, memory, and I/O devices to a common bus. * Design simple I/O (input/output) interfaces.
* Define the decoding and interconnection of the major components. * Perform a worst-case analysis of the timing and loading of all signals. * Understand the software development cycle for a microcontroller. * Debug and test the hardware and software designs.
These tasks represent the major skills required in the successful applicationof an embedded micro. In addition, other abilities—such as the design andimplementation of simple user programmable logic—will be covered asrequired to support the proficient application of the technology.
Embedded Microcomputer Applications
There is an incredible diversity of applications for embedded processors.Most people are aware of the highly visible applications, but there are manyless apparent uses. Many of t
桂林电子科技大学毕业设计(论文)专用纸 第 5 页 共26页
he projects my students have chosen turned outto be of practical use in their work. However, they have covered the entirerange from the economically practical to the blatantly absurd. One practicalexample was the use of a microprocessor to monitor and control the ratio ofingredients used in mixing concrete. About a year after the student imple-mented the system, he wrote to inform me that the system had saved his com-pany between two and three million dollars a year by reducing the number of “bad batches” of concrete that had to be jack hammered out and replaced.
Another example was that of a student who suspended a ball by airflow gener-ated by a fan and provided closed loop control of the ball’s position with themicroprocessor. The only thing that many of the student projects really hadin common was the use of a microcontroller as a tool.Some of the actual commercial applications of embedded computer controlsthat the author has been directly involved with include:
* A belt measures a person’s heart rate and respiration that signals an alarmwhen safe limits are exceeded. A radio signal is then transmitted to amicrocontroller in a pocket pager to display the type of problem and theidentity of the belt.
* An environmental system controls the heating ventilating and air condi-tioning in one or more large buildings to minimize peak energy demands.
* A system that measures and controls the process of etching away theunwanted portions of material from the surface of an integrated circuitbeing manufactured.
* The fare collection system used to monitor and control entry to a rapidtransit system based on the account balance stored on the magnetic stripeon a card.
* Determination of exact geographic position on the earth by measuring thetime of arrival of radio signals received from navigational beacons.
* An intelligent phone that receives radio signals from smoke alarms, intru-sion sensors, and panic switches to alert a central monitoring station topotential emergency situations. * A fuel control system that monitors and controls the flow of fuel to aturbine jet engine.
Selecting a particular processor for a given application is usually a function ofthe designer’s familiarity with a particular architecture. While there are manyvariations in the details