Preface

[Enlightenment] resides as comfortably in the circuits of a digital computer . . . as at the top of a mountain or in the petals of a flower.

Robert M. Pirsig, Zen and the Art of Motorcycle Maintenance

This is a book about designing computer hardware and specifically about designing small machines for embedded applications. It is intentionally hardware specific. There are plenty of books out there on writing code for embedded systems (such as Michael Barr’s excellent Programming Embedded Systems in C and C++, another O’Reilly & Associates title). What has been missing is a book that covers the nuts and bolts of developing embedded hardware. Sure, there are many books out there on microprocessors, but none that brings together all you need to create an embedded computer and make it go.

This is a book I have wanted to write for some time. It had its origins back in 1993, when I was lecturing at La Trobe University in Melbourne, Australia. I was given the task (at the last possible moment) of teaching a course in microprocessors to second-year students. The assigned text for the course was far from ideal. It talked about computer hardware but didn’t show how to design computer hardware. It took a Field of Dreams approach—build it and it will go, with no consideration of timing, voltages, current draw, or anything else of importance. It was a newly published book, yet it covered components that had not been available for years. The memory chips it discussed were 128 bytes in capacity. (That’s 128 bytes, not kilobytes!) This was a book that was neither relevant nor useful.

After talking to numerous representatives of publishing companies, I soon discovered that there wasn’t much better available. And so, I solved the problem by writing detailed lecture notes for the students and told them to forget the textbook. These lecture notes were written quickly, and as a result, they were very rough indeed. The lectures were used to smooth the edges and fill the gaps. One day, I resolved, I would write a proper book.

And now, the opportunity has arisen to write for O’Reilly, and the book has become a reality. I no longer teach at La Trobe, having left many years ago to found my own company. More than ever, I want to bring together the real-world knowledge and experience necessary to construct working embedded systems. This book looks at the design process for creating and building embedded hardware and the analysis process for confirming that it will work. I will assume nothing about your knowledge beyond a rudimentary understanding of digital and analog electronics. The only real prerequisite is that you are intelligent and have an analytical mind. As I said at the start, this book is about hardware, and so you won’t find software in these pages. That is better covered elsewhere.

Just as there is beauty in well-written software, there is beauty in well-designed hardware. With embedded computers, you get to understand the machine at all levels, at once aware of currents flowing through circuit traces and software executing complex algorithms. In fact, it is not possible to write embedded software without understanding the hardware, nor is it possible to design hardware without understanding software. You become involved with the machine to a degree beyond that which is possible with desktop computers. Best of all, it’s a lot of fun.

In selecting chips and designs for this book, I have deliberately chosen parts that are both trivial to implement yet exceptionally useful. Aside from my own company (Embedded), I have no connection, financial or otherwise, with any of the companies or businesses mentioned in this book. You may, however, notice a prevalence of components from certain manufacturers. This simply reflects my personal preference for using their chips, based on my experience. Such companies produce chips that are easy to use, are reliable and robust, have great technical support, and provide thorough and comprehensive technical data. In other words, they have all the necessary prerequisites for inclusion in a book for beginners.

Many of the designs in this book look easy, and they are. They are intended as simple building blocks, allowing you to mix and match to achieve the embedded systems you need. There are some very complicated processors and support chips out there, and designs based upon them can be horrendously complicated, confusing, and frustrating. You won’t find them in this book. This book is aimed at developing small, low-cost, and relatively simple embedded applications. I hope you will find it useful.

Organization of This Book

This book is divided into three parts. Part I covers fundamental concepts and introductory material. Part II looks at embedded processors and the design process for integrating them into systems. Part III looks at peripherals and adding functionality to your embedded systems.

Chapter 1 presents an overview of computer architectures and discusses the basics of an embedded system. Chapter 2 provides some background electronics theory and introduces some important concepts. If you’re already electronics-savvy, then you can skip on to Chapter 3, which covers providing power for your embedded system. In Chapter 4, you’ll see how to physically produce and debug an embedded computer system. We’ll also look at how to protect your embedded computer against electrical interference and other gremlins that can cause it grief.

Chapter 5 begins Part II of the book, where you’ll encounter the first of the embedded processor architectures, the Microchip PIC. The PICs are tiny, self-contained computers that make building embedded systems easy and fun. Chapter 6 discusses the ATMEL AVR, another embedded processor ideally suited to small-scale, simple applications. You’ll also learn how to add additional memory and peripherals to bus-based processors and discover the basics of memory management. With Chapter 7, we take a look at the Motorola 68000 series of processors. These chips have been around for quite some time and are still widely used. They are also a good starting point if you want to get into more complicated processors once you have more embedded experience. Chapter 8 examines processors based on Digital Signal Processing (DSP) architectures. These processors are adept at mathematically intensive and complex algorithms and are especially suited to control and sampling applications (such as the processing of digital signals).

In Part III of the book, you’ll learn how to add function to your embedded computers by using peripherals. Chapter 9 covers SPI and I2C, two protocols that allow a wide range of small peripherals to be added to microcontrollers. Chapter 10 covers serial interfaces. These give your embedded system access to host computers and to external peripherals such as modems. We’ll also take a look at RS-232C, RS-422, infrared communication, and USB. Networks are covered in Chapter 11, where you’ll see how to add two low-cost industrial networks (RS-485 and CAN) to your embedded computer. Also in Chapter 11, you’ll learn how to add an Ethernet port to your embedded system, by which you can connect to other computers, servers, and gateways and, through them, to the Internet. Finally, Chapter 12 looks at real-world interfacing. You’ll learn how to convert analog signals into digital values for processing and, conversely, how to convert digital values back into analog voltages. You’ll learn how to measure temperature, light, pressure, acceleration, and magnetic fields in your embedded system using sensors, as well as how to use an embedded computer to control small electric motors.

Get Designing Embedded Hardware now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.