INTRODUCTION

This book and its accompanying website—www.reesemicro.com—are intended as an introduction to microprocessors (μPs) and microcontrollers (μCs) for the student or hobbyist. The book structure is as follows:

image Chapter 1: Review of digital logic concepts.

image Chapter 2: Computer architecture fundamentals.

image Chapters 3 through 6: Coverage of assembly language programming in a C language context using the PIC24 family.

image Chapter 7: Advanced assembly language programming structured around computer arithmetic topics.

image Chapters 8 through 12: Fundamental microcontroller interfacing topics such as parallel IO, asynchronous serial IO, synchronous serial IO (I2C and SPI), interrupt-driven IO, timers, analog-to-digital conversion, and digital-to-analog conversion.

image Chapter 13: Some advanced interfacing topics such as DMA, the ECAN standard, and slave/multi-master I2C operations.

image Chapter 14: An advanced chapter that covers the basics of real-time operating systems using a cooperative multitasking OS written by the authors. Topics include tasks, schedulers, scheduling algorithms, task synchronization and communication, semaphores, mailboxes, and queues.

image Chapter 15: Advanced techniques and examples for use in a senior capstone design course. This chapter is available online only at www.reesemicro.com.

image Appendix A: A compact summary of the PIC24E/dsPIC33E instruction set.

image Appendix B: A hobbyist-level introduction to basic circuits. It covers the basic components (resistors, capacitors, and diodes) used in this book’s schematics.

image Appendix C: Solutions to odd-numbered end-of-chapter problems.

image Appendix D: References.

This Book’s Development

At Mississippi State University, majors in Electrical Engineering (EE), Computer Engineering (CPE), Computer Science (CS), and Software Engineering (SE) take our first course in microprocessors. Previous to Spring 2002, this course emphasized X86 assembly language programming with the lab experience being 100 percent assembly language based and containing no hardware component. We found that students entering our senior design course, which has the expectation of something “real” being built, were unprepared for doing prototyping activities or for incorporating a microcontroller component into their designs. We did offer a course in microcontrollers, but it was an elective senior-level course and many students had not taken that course previous to senior design. In Spring 2002, the Computer Engineering Steering Committee reexamined our goals for the first course in microprocessors, and the approach for this book’s predecessor (From Assembly Language to C Using the PIC18Fxx2) was developed. From Fall 2003 through Spring 2004, we used the Microchip PIC16 family, and then used the PIC18 family from Summer 2004 through Spring 2008. In late Fall 2007, the authors reexamined the course once again and decided to switch to the PIC24 family because of its rich instruction set architecture, 16-bit organization, and advanced on-chip peripherals. In 2013, significant advances in the field prompted the second edition, which focuses on the redesigned and improved PIC24E/dsPIC33E family of PIC24/dsPIC33 microprocessors.

Using This Book in an Academic Environment

This book is intended for use as a first course in microcontrollers/microprocessors (μC/μP) using the PIC24 family, with prerequisites of basic digital design and exposure to either C or C++ programming. The book begins with simple microprocessor architecture concepts, moves to assembly language programming in a C language context, and then covers fundamental hardware interfacing topics such as parallel IO, asynchronous serial IO, synchronous serial I/O (I2C and SPI), interrupt-driven IO, timers, analog-to-digital conversion, and digital-to-analog conversion. Programming topics are discussed using both assembly language and C, while hardware interfacing examples use C to keep code complexity low and improve clarity. The assembly language programming chapters emphasize the linkage between C language constructs and their assembly language equivalent so that students clearly understand the impact of C coding choices in terms of execution time and memory requirements. A textbook with an assembly-only focus creates students who are experts only in assembly language programming, with no understanding of high-level language programming techniques and limited hardware exposure. Most embedded software is written in C for portability and complexity reasons, which argues favorably for reduced emphasis on assembly language and increased emphasis on C. Embedded system hardware complexity is steadily increasing, which means a first course in μC/μP that reduces assembly language coverage (but does not eliminate it) in favor of hands-on experience with fundamental interfacing allows students to begin at a higher level in an advanced course in embedded systems, the approach chosen for this textbook.

Hardware interface topics included in this book cover the fundamentals (parallel IO, serial IO, interrupts, timers, analog-to-digital conversion, digital-to-analog conversion) using devices that do not require extensive circuits knowledge because of the lack of a circuits course prerequisite. The microcontroller interfacing topics presented in this textbook are sufficient for providing a skill set that is extremely useful to a student in a senior design capstone course or in an advanced embedded system course.

Thus, a principal motivation for this book is that microcontroller knowledge has become essential for successful completion of senior capstone design courses. These capstone courses are receiving increased emphasis under ABET 2000 guidelines. This places increased pressure on Computer Engineering and Electrical Engineering programs to include significant exposure to embedded systems topics as early in the curriculum as possible. A second motivation for this book is that the ACM/IEEE Computer Engineering model curriculum recommends 17 hours of embedded system topics as part of the Computer Engineering curriculum core, which is easily satisfied by a course containing the topics in this book. A third motivating factor is the increased pressure on colleges and universities to reduce hours in engineering curriculums; this book shows how a single course can replace separate courses in assembly language programming and basic microprocessor interfacing.

The course sequence used at Mississippi State University that this book fits into is as follows:

image Basic digital design (Boolean algebra and combinational and sequential logic), which is required by EE, CPE, CS, and SE majors.

image Introduction to microprocessors (this book), which is required for EE, CPE, CS, and SE majors.

image Computer architecture as represented by the topic coverage of the Hennessy and Patterson textbook, Computer Organization & Design: The Hardware/Software Interface. This includes reinforcement of the assembly language programming taught in the microprocessor course via a general-purpose instruction set architecture (e.g., the MIPS), along with coverage of traditional high-performance computer architecture topics (pipelined CPU design, cache strategies, and parallel bus I/O). Required for CPE, CS, and SE majors.

image Advanced embedded systems covering topics such as real-time operating systems, Internet appliances, and advanced interfaces such as USB, CAN, Ethernet, and FireWire. Required for CPE majors.

Chapter 1 provides a broad review of digital logic fundamentals. Chapters 2 through 6 and 8 through 13 cover the core topics of assembly language programming and microcontroller interfacing. Chapters 7 and 14 have optional topics on advanced assembly language programming and the basics of real-time operating systems, which can be used to supplement the core material. The accompanying website provides a sequence of 11 laboratory experiments that comprise an off-the-shelf lab experience: one experiment on fundamental computer architecture topics, four experiments on PIC24 assembly language, and six hardware experiments. In addition, the website provides Chapter 15 of the textbook in an online form; this chapter demonstrates a set of techniques and projects that integrate and supplement material from the previous chapters.

The hardware labs cover all major subsystems on the PIC24 μC: A/D, timers, asynchronous serial interface, SPI, and the I2C interface. The hardware experiments are based on a breadboard/parts kit approach where the students incrementally build a PIC24 system that includes a serial EEPROM, an external 8-bit DAC, and an asynchronous serial port via a USB-to-serial cable. A breadboard/parts kit approach is used instead of a preassembled printed circuit board (PCB) for several important reasons:

image When handed a preassembled PCB, students tend to view it as a monolithic element. A breadboard/parts kit approach forces students to view each part individually and read datasheets to understand how parts connect to each other.

image Hardware debugging and prototyping skills are developed during the painful process of bringing the system to life. These hard-won lessons prove useful later when students must do the same thing in a senior design context. This also provides students with the confidence that, having done it one time, they can do it again—this time outside of a fixed laboratory environment with guided instruction.

image A breadboard/parts kit approach gives the ultimate flexibility to modify experiments from semester to semester by simply changing a part or two; also, when the inevitable part failures occur, individual components are easily replaced.

In using this laboratory approach at Mississippi State University, the authors have seen a “Culture of Competence” develop in regard to microcontrollers and prototyping in general. All senior design projects now routinely include a microcontroller component (not necessarily Microchip-based). Students concentrate their efforts on design definition, development, and refinement instead of spending most of their time climbing the learning curve on prototyping and microcontroller usage.

There are more topics in this book than can be covered in a 16-week semester. In our introductory microprocessor course, we cover Chapters 1 through 6 for the assembly language coverage (about 6 weeks) and selected topics from Chapters 8 through 12 for the interfacing component. A course with more emphasis on assembly language may include Chapter 7 and fewer interfacing topics.

Our follow-on embedded systems course uses Chapters 8 through 14, with an emphasis on writing applications using the embedded operating system approach described in Chapter 14 and a more in-depth coverage of all interfacing topics. A first course in microcontrollers that contains no assembly language component may want to assign Chapters 1 through 7 as background reading and use Chapters 8 through 14 as the primary course material.

This book’s C examples on hardware interfacing strive for code clarity first and optimization second. A prefix naming convention (u8_, u16_, i32_, pu8_, and so on) is used for all variables, and a robust set of macros and library functions have been developed to make access to the on-chip resources easier for those encountering microcontrollers for the first time. The library functions emphasize run-time error trapping and reporting as a way of shedding more light on malfunctioning applications. Please check the www.reesemicro.com website for updates to the library functions.

For the Hobbyist

This book assumes very little background, and thus is appropriate for readers with widely varying experience levels. First, read Chapter 8 and visit the companion website at www.reesemicro.com to build and install the hardware and software PIC24 development environment. Next, peruse the example programs at this website and find the ones that interest you. Then, read the chapter that is referenced by the experiment for the necessary background. This textbook includes numerous examples complete with schematics and working code to operate a number of useful peripherals, including temperature sensors, LCD displays, and RC servo control, providing a good starting point for your designs.

Final Thoughts

We hope readers have as much fun exploring the world of μCs/μPs and the PIC24 family as the authors had in creating this text. Because we know that μC/μP development does not sit still, let us all look forward to new learning experiences beyond this text.

Bryan A. Jones, Bob Reese, and J. W. Bruce
Mississippi State University
Starkville, Mississippi

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.138.33