Файл: Embedded Controller Hardware Design (Ken Arnold, 2001).pdf
ВУЗ: Не указан
Категория: Не указан
Дисциплина: Не указана
Добавлен: 13.06.2025
Просмотров: 2641
Скачиваний: 0
x Preface
and detailed. The 8051 was chosen because it can be interfaced to external memory, has simple timing specs, is widely used and available from a number of manufacturers. The concepts of worst-case design and analysis are described, along with techniques for hardware interfacing. A good embedded design requires 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 an introduction to the 8051’s bus interface. Most embedded designs can also benefit from the use of user programmable logic devices (PLD). This subject is too complex for in-depth coverage here, so PLD technology is covered from a relatively high level. The central theme of designing an embedded system that 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, and several design alternatives are evaluated. With the central part of the design completed, the remaining chapters cover the various types of I/O interfaces, bus operations, and a collection of information that is seldom included in the usual 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 observations and contributions you may have. If you should find any errors in the text, or if you know of some good embedded design resources, please feel free to contact me directly by e-mail: ken.arnold@ieee.org
1 |
|
CHAPTER ONE |
1 |
Review of Electronics
Fundamentals
Why are microprocessors and microcontrollers designed into so many different devices? While there are many dry and practical reasons, I suspect one of the strongest 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 seen many products and projects that could have been handled without resorting to a microprocessor. Yet there is always a tendency to rationalize the choice of a micro-based solution by economic or technical arguments to support the decision. In fact, most of the really excellent products were successful to a great extent because they were fun to develop. Many of the best product ideas have occurred when someone was “playing” with something they were interested in. In my own experience, I have found learning something new is much easier and more effective when I am “just playing around” rather than trying to learn in a structured way or against a deadline. Studies of various educa tional methods also indicate “coached exploration” is more effective than the traditional methods. These and other observations lead me to the conclusion that the best way to learn about a microcontroller is by “playing” with one.
No book—no matter how well written—can possibly motivate and educate you as well as building and playing with a microcontroller. The best way to learn the concepts in this book is to build a simple microcontroller. Even if it is capable of nothing more than blinking a light, it will provide a concrete example of the microcontroller as a tool that can be fun to use. To ease this effort, a companion system development kit (SDK), is available to accompany this 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 embedded controller design. The design is included on the CD-ROM and web site for this book, so anyone can reproduce and use it as a learning tool. By applying
2EMBEDDED CONTROLLER
Hardware Design
the guidelines set forth in this book to real world hardware, you can learn to design reliable embedded hardware into other products. Information on obtaining 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 application of an embedded micro. In addition, other abilities—such as the design and implementation of simple user programmable logic—will be covered as required 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 many less apparent uses. Many of the projects my students have chosen turned out to be of practical use in their work. However, they have covered the entire range from the economically practical to the blatantly absurd. One practical example was the use of a microprocessor to monitor and control the ratio of ingredients 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
3CHAPTER ONE
Review of Electronics Fundamentals
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 the microprocessor. The only thing that many of the student projects really had in common was the use of a microcontroller as a tool.
Some of the actual commercial applications of embedded computer controls that the author has been directly involved with include:
•A belt measures a person’s heart rate and respiration that signals an alarm when safe limits are exceeded. A radio signal is then transmitted to a microcontroller in a pocket pager to display the type of problem and the identity 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 the unwanted portions of material from the surface of an integrated circuit being manufactured.
•The fare collection system used to monitor and control entry to a rapid transit system based on the account balance stored on the magnetic stripe on a card.
•Determination of exact geographic position on the earth by measuring the time 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 to potential emergency situations.
•A fuel control system that monitors and controls the flow of fuel to a turbine jet engine.
Selecting a particular processor for a given application is usually a function of the designer’s familiarity with a particular architecture. While there are many variations in the details and specific features, there are two general categories of devices: microprocessors and microcontrollers. The key difference between a microprocessor and a microcontroller is that a microprocessor contains only a central processing unit (CPU) while a microcontroller has memory and I/O on the chip in addition to a CPU. Microcontrollers are generally used for dedicated tasks. Microcomputer is a general term that applies to complete com puter systems implemented with either a microprocessor or microcontroller.
4EMBEDDED CONTROLLER
Hardware Design
Microcomputer and Microcontroller Architectures
Microprocessors are generally utilized for relatively high performance appli cations where cost and size are not critical selection criteria. Because micro processor chips have their entire function dedicated to the CPU and thus have room for more circuitry to increase execution speed, they can achieve very high-levels of processing power. However, microprocessors require external memory and I/O hardware. Microprocessor chips are used in desktop PCs and workstations where software compatibility, performance, generality, and flexibility are important.
By contrast, microcontroller chips are usually designed to minimize the total chip count and cost by incorporating memory and I/O on the chip. They are often “application specialized” at the expense of flexibility. In some cases, the microcontroller has enough resources on-chip that it is the only IC required for a product. Examples of a single-chip application include the key fob used to arm a security system, a toaster, or hand-held games. The hardware interfaces of both devices have much in common, and those of the microcontrollers are generally a simplified subset of the microprocessor. The primary design goals for each type of chip can be summarized this way:
•microprocessors are most flexible
•microcontrollers are most compact
There are also differences in the basic CPU architectures used, and these tend to reflect the application. Microprocessor based machines usually have a von Neumann architecture with a single memory for both programs and data to allow maximum flexibility in allocation of memory. Microcontroller chips, on the other hand, frequently embody the Harvard architecture, which has separate memories for programs and data. Figure 1-1 illustrates this difference.
Program |
Data |
Program |
|||
CPU |
and Data |
CPU |
|||
Memory |
Memory |
||||
Memory |
|||||
Figure 1-1: At left is the von Neumann architecture; at right is the Harvard architecture.
One advantage the Harvard architecture has for embedded applications is due to the two types of memory used in embedded systems. A fixed program and constants can be stored in non-volatile ROM memory while working variable
5CHAPTER ONE
Review of Electronics Fundamentals
The peripherals on a microcon |
Microprocessor |
Devices |
||||
troller chip are typically timers, |
||||||
Functions |
||||||
counters, serial or parallel data |
||||||
ports, and analog-to-digital and |
||||||
digital-to-analog converters |
||||||
that are integrated directly on |
CPU |
Memory |
I/O |
|||
the chip. The performance of |
||||||
these peripherals is generally |
||||||
less than that of dedicated |
||||||
peripheral chips, which are |
||||||
frequently used with microprocessor chips. However, having the bus connec tions, CPU, memory, and I/O functions on one chip has several advantages:
•Fewer chips are required since most functions are already present on the processor chip.
•Lower cost and smaller size result from a simpler design.
•Lower power requirements because on-chip power requirements are much smaller than external loads.
•Fewer external connections are required because most are made on-chip, and most of the chip connections can be used for I/O.
•More pins on the chip are available for user I/O since they aren’t needed for the bus.
•Overall reliability is higher since there are fewer components and interconnections.
6EMBEDDED CONTROLLER
Hardware Design
Of course there are disadvantages too, including:
•Reduced flexibility since you can’t easily change the functions designed into the chip.
•Expansion of memory or I/O is limited or impossible.
•Limited data transfer rates due to practical size and speed limits for a single-chip.
•Lower performance I/O because of design compromises to fit everything on one chip.
Digital Hardware Concepts
In addition to the CPU, memory, and I/O building blocks, other logic circuits may also be required. Such logic circuits are frequently referred to as glue logic because they are used to connect the various building blocks together. The most difficult and important task the hardware designer faces is the proper selection and specification of this “glue logic.” Devices such as registers, buffers, drivers and decoders are frequently used to adapt the control signals provided by the CPU to those of the other devices. While TTL gate level logic is still in use for this purpose, the programmable logic device (PLD) has be come an important device in connecting the building blocks. Contemporary microcontroller designers need to acquire the following skills:
•Interpretation of manufacturers specifications
•Detailed, worst case timing analysis and design
•Worst case signal loading analysis
•Design of appropriate signal and level conversion circuits
•Component evaluation and selection
•Programmable logic device selection and design
The glue logic used to join the processor, memories, and I/O is ultimately composed of logic gates, which are themselves composed almost entirely of transistors, diodes, resistors, and interconnecting wires. In order to under stand the basic operation of the glue logic, we are going to begin at the com ponent level with a review of basic electronics concepts. These concepts will be presented as fluid flow analogies.
7CHAPTER ONE
Review of Electronics Fundamentals
Voltage, Current, and Resistance
In Figure 1-3, a battery provides |
Voltage Source |
a voltage source for electricity, |
much like a pump provides a pressure source for a fluid. Voltage, or pressure, is required to produce current flow in the circuit.
Pressure is analagous to Voltage
The voltage source provides the pressure “motivation,” if you will,
for current flow. Resistance provides a limiting constraint on the
amount of current that will actually flow. The resistor will allow a current to flow through it that is proportional to the voltage across it, and inversely proportional to the resistance value. Higher resistance is like a smaller aperture for the fluid to flow through. The
resistance results in a voltage, or pressure drop, across the resistance as long as current is
flowing in the resistor. Figure 1-4 illustrates this.
The wiring connecting the com ponents in a circuit is like the piping connecting plumbing components that let a fluid flow. The flow of current in the circuit
is controlled by the magnitude of the voltage (pressure) and the resistance (pressure drop) in the circuit. In Figure 1-5, the battery provides a voltage to force current through the resistor. The magnitude of the voltage (V) generated by the battery is developed across the resistor, and the magnitude of the resis tance (R), determine the current (I). Note the “return” current path is often shown as “ground,” which is the reference voltage used as the “zero volts” point. In this case, current flows from the positive battery terminal, through the wire, then the resistor, then through the “ground” connection to the minus terminal of the battery. This is usually not the same as earth ground, which provides a connection to a stake or pipe literally stuck in the ground. The magnitude of the current in this case is I = V / R by re-arranging the