During the summer of 1992, the first author (D.P.) was first introduced to the family of Motorola 68HC 11 Microcontrollers as he was constructing an interface module between a Puma robot arm robot controller and a force-torque sensor. Since then, he has become aware of the power of microcontrollers and their unlimited applications. Fortunately, as a professor of electrical engineering at the U.S. Air Force Academy, he has had ample opportunities to share his microcontroller experience with students. In the fall of 1995 at the Academy, he met the second author (S.B.), a friend, mentor, and, at that time, his immediate boss. Soon after the first author's arrival at the Academy, S.B. started to share his expert knowledge on digital systems with D.P., and D.P. has benefited tremendously to this point. Over time, we decided to share our work in a more concrete form. That is when we decided to write a book on the 68HC 12.
One of the most compelling reasons to write 68HC12 Book is that Motorola is slowly phasing out the popular 68HC 11 microcontroller-based evaluation boards and replacing them with the 68HC 12. The 68HC 11 family of microcontrollers have been the preferred choice of educators due to their built-in input and output (I/O) capabilities, a variety of timer functions, and platforms for easy programming and interfacing. The 68HC 12 retained all the favorable features of the 68HC 11 (in fact, one can run any 68HC 11 code on the 68HC 12 with minor modifications) and increased the computational power while enhancing hardware and software components. Compared to its predecessor, the 68HC12 has reduced the interrupt latency time, increased the I/O capacity, added complex math operations, incorporated fuzzy logic functions, and improved the overall system performance by adapting a mechanism called instruction queuing, which is similar to the pipelining s6heme found in more powerful microprocessors. This book is about the 68HC 12; we show how to program and uncover the possibilities of 68HC 12 applications.
This book is written for undergraduate students taking a microcontroller or microprocessor course, frequently found in electrical engineering and computer engineering curricula. These courses aim to teach students the fundamental knowledge of microcontrollers/microprocessors and techniques to interface them with external devices, pointing out the important role of embedded microcontroller systems in our modern society. The book is designed to assist instructors to fulfill such course objectives by combining both the theory and applications of microcontrollers. In particular, we chose the 68HC12 microcontroller since it is becoming the industry standard.
We expect students to have taken an introductory logic course and a freshmen programming language course. For a quick review of digital logic, we included Appendix D. Having taken a computer language course will help students understand how assembly language programs are related to high-level language programs, but we expect students with a minimal exposure to computer programming will follow the text subjects without too much trouble.
We must also address one other category of readers. Although the book is mainly designed for students learning the subject in an academic setting, it can be easily adopted by engineers who want to learn the subject on their own. Since the underlying concepts and functional components of two different types of microcontrollers are very similar to each other, the acquired knowledge of the 68HC12 can naturally be applied to other microprocessors and microcontrollers. Such knowledge is essential for electrical and computer engineering students as we live in a society where more and more engineering problems are solved by embedded microcontrollers. In fact, we find the scope of actual applications of microcontrollers expanding as new problems are encountered and solved by the engineering community.
We have three objectives for writing this book; we want you to learn (1) fundamental assembly language programming skills, (2) functional hardware components of a microcontroller, and (3) skills to interface a variety of external devices with microcontrollers. The entire book is designed with those three objectives in mind. As you already know, skills cannot be mastered without practice, and we encourage you to program and try the examples as you read. The enclosed software on the back of the book provides a convenient means to write, edit, assemble, and execute your programs. We have included lots of examples and applications to introduce you to some of the important uses of the 68HC12 controller.
Among the many examples, you will find a set of mobile robot applications throughout the book. We included these applications for their pedagogical advantages learned from our own experience for using them in our microcontroller courses. In fact, the mobile robot applications not only made students appreciate the range of tasks the controller can perform, but also helped the students to understand and integrate multiple subject topics in a single project.
Each year, the student response has been nothing short of enthusiastic. The students consistently pointed out the value of the mobile robot applications that provided students with an experience to develop a hands-on working knowledge of the microcontroller. We hope you will take full advantage of the text by creating and developing your own mobile robots. Appendix E contains the information necessary for you to acquire parts to construct your own robot. The applications are, however, not limited to the robot applications. You will find an ample amount of nonrobot applications throughout the book.
In organizing each chapter, we gave a great deal of consideration to the order and means of subject presentations. The assembly language programming techniques are studied in the first portion of the book, whereas the rest of the book is dedicated to the controller hardware and how to program the hardware components to interface the controller with external devices. Each chapter starts with a list of chapter objectives to give you a clear purpose for reading the entire chapter. Following the objectives, you will also find an introductory subsection for each chapter, informing you of the section contents. After the main body of a chapter is presented, starting in Chapter 3, you will find an application section, where a particular application is chosen to illustrate the subjects contained in the chapter. We study the chapter subjects once again in the laboratory application section, which follows the application section.
A laboratory application section contains the mobile robot laboratory exercises associated with the chapter subject. The 11 exercises can be used as a set of optional, fun activities as you read this book or as a part of a course requirement. Figure 1 provides an overview of where each laboratory exercise fits in the development of the overall mobile robot control program.
The first five labs found in Chapters 2 through 4 will provide you with opportunities to exercise fundamental assembly language programming skills. Chapter 2 laboratory exercise A teaches you how to use the enclosed software editor, assembler, loader, and the 68HC12 built-in monitor commands. Chapter 2 laboratory exercise B is designed for you to write a simple assembly language program using some basic instructions as well as if-then-else programming constructs (branch instructions). This laboratory exercise is later modified to make navigational decisions for the mobile robot based on infrared sensor values. In Chapter 3 laboratory exercise A, you will write a program with two subroutines, applying two parameter passing methods to generate simulated motor speed profiles. Continuing the subroutine theme, Chapter 3 laboratory exercise B will show you how to access built-in D-bug12 I/O subroutines: You will write a program to display the motor speed profiles on a PC screen using appropriate I/O subroutines. The skills learned in this laboratory exercise are later used to debug other programs. Chapter 4 laboratory exercise gives you the first chance to program a fuzzy logic controller using special 68HC12 fuzzy logic instructions. The fuzzy controller uses a set of three IR sensor inputs and computes a navigational decision, simulating robot motions in a maze. By the end of this lab, we expect you to be comfortable with writing, assembling, running, and debugging small assembly language programs. In addition, you will have a library of routines that form the basis of the final robot control program.
The next six exercises in Chapters 5 through 9 are hardware intensive while we continue to reinforce learned and introduce new programming techniques; we extend your ability to program the controller's hardware modules. Chapter 5 laboratory exercise lets you interface a basic external switch with the 68HC 12. The lab can 'also be used to practice implementing a technique called polling. Chapter 6 laboratory exercise teaches students to write a program that incorporates an external interrupt. In addition, you will continue to build your I/O interface skills by controlling the display of an AND671 8-bit Liquid Crystal Display unit with the 68HC12. Chapter 7 laboratory exercises A and B are designed to teach you to program the timer function modules and the I/O ports of the 68HC 12. In these exercises, you will write programs to control the direction and speed of the mobile robot by generating pulse-width-modulated signals and control signals for two DC motors. These lab exercises build on Chapter 5 laboratory exercise and exploit the real-time I/O hardware. Chapter 9 laboratory exercise focuses on the built-in analog-to-digital (ATD) converter. Finally, the last lab exercise found in Chapter 10 gives you an opportunity to combine your accumulated 68HC12 hardware knowledge, assembly language programming skills, and hardware interfacing skills to c...