- •Table of Contents
- •Preface
- •Additional Material
- •Basic Electronics
- •1.0 The Atom
- •1.1 Isotopes and Ions
- •1.2 Static Electricity
- •1.3 Electrical Charge
- •1.4 Electrical Circuits
- •1.5 Circuit Elements
- •1.6 Semiconductors
- •Number Systems
- •2.0 Counting
- •2.1 The Origins of the Decimal System
- •2.2 Types of Numbers
- •2.3 Radix Representations
- •2.4 Number System Conversions
- •Data Types and Data Storage
- •3.0 Electronic-Digital Machines
- •3.1 Character Representations
- •3.2 Storage and Encoding of Integers
- •3.3 Encoding of Fractional Numbers
- •3.4 Binary-Coded Decimals (BCD)
- •Digital Logic, Arithmetic, and Conversions
- •4.0 Microcontroller Logic and Arithmetic
- •4.1 Logical Instructions
- •4.2 Microcontroller Arithmetic
- •4.3 Bit Manipulations and Auxiliary Operations
- •4.4 Unsigned Binary Arithmetic
- •4.5 Signed Binary Arithmetic
- •4.6 Data Format Conversions
- •Circuits and Logic Gates
- •5.0 Digital Circuits
- •5.1 The Diode Revisited
- •5.2 The Transistor
- •5.3 Logic Gates
- •5.4 Transistor-Transistor Logic
- •5.5 Other TTL Logic Families
- •5.6 CMOS Logic Gates
- •Circuit Components
- •6.0 Power Supplies
- •6.1 Clocked Logic and Flip-flops
- •6.2 Clocks
- •6.3 Frequency Dividers and Counters
- •6.4 Multiplexers and Demultiplexers
- •6.5 Input Devices
- •The Microchip PIC
- •7.0 The PICMicro Microcontroller
- •7.1 PIC Architecture
- •Mid-range PIC Architecture
- •8.0 Processor Architecture and Design
- •8.1 The Mid-range Core Features
- •8.2 Mid-Range CPU and Instruction Set
- •8.3 EEPROM Data Storage
- •8.4 Data Memory Organization
- •8.5 Mid-range I/O and Peripheral Modules
- •PIC Programming: Tools and Techniques
- •9.0 Microchip’s MPLAB
- •9.1 Integrated Development Environment
- •9.2 Simulators and Debuggers
- •9.3 Programmers
- •9.4 Engineering PIC Software
- •9.5 Pseudo Instructions
- •Programming Essentials: Input and Output
- •10.0 16F84A Programming Template
- •10.1 Introducing the 16F84A
- •10.2 Simple Circuits and Programs
- •10.3 Programming the Seven-segment LED
- •10.4 A Demonstration Board
- •Interrupts
- •11.0 Interrupts on the 16F84
- •11.1 Interrupt Sources
- •11.2 Interrupt Handlers
- •11.3 Interrupt Programming
- •11.4 Sample Programs
- •Timers and Counters
- •12.0 The 16F84 Timer0 Module
- •12.1 Delays Using Timer0
- •12.2 Timer0 as a Counter
- •12.3 Timer0 Programming
- •12.4 The Watchdog Timer
- •12.5 Sample Programs
- •LCD Interfacing and Programming
- •13.0 LCD Features and Architecture
- •13.1 Interfacing with the HD44780
- •13.2 HD44780 Instruction Set
- •13.3 LCD Programming
- •13.4 Sample Programs
- •Communications
- •14.0 PIC Communications Overview
- •14.1 Serial Data Transmission
- •14.2 Parallel Data Transmission
- •14.4 PIC Protocol-based Serial Programming
- •14.5 Sample Programs
- •Data EEPROM Programming
- •15.0 PIC Internal EEPROM Memory
- •15.1 EEPROM Devices and Interfaces
- •15.2 Sample Programs
- •Analog to Digital and Realtime Clocks
- •16.0 A/D Converters
- •16.1 A/D Integrated Circuits
- •16.2 PIC On-Board A/D Hardware
- •16.3 Realtime Clocks
- •16.4 Sample Programs
- •Index
Preface
There are two sides to the computer revolution: one is represented by the PC on your desktop and the second one by the device that remote-controls your TV, monitors and operates your car engine, and allows you to set up your answering machine and your microwave oven. At the core of the PC you find a microprocessor, while at the heart of a self-contained programmable device (also called an embedded system) is a microcontroller.
Microcontrollers are virtually everywhere in our modern society. They are found in automobiles, airplanes, toys, kitchen appliances, computers, TVs and VCRs, phones and answering machines, space telescopes, and practically every electronic digital device that furnishes an independent functionality to its user. In this sense a microcontroller is a self-contained computer system that includes a processor, memory, and some way of communicating with the outside world, all in a single chip that can be smaller than a postage stamp.
A microcontroller (sometimes called an MCU) is actually a computer on a chip.
Essentially it is a control device and its design places emphasis on being self-suffi- cient and inexpensive. The typical microcontroller contains all the components and features necessary to perform its functions, such as a central processor, input/output facilities, timers, RAM memory for storing program data and executable code, and a clock or oscillator that provides a timing beat. In addition, some microcontrollers include a variety of additional modules and circuits. Some common ones are serial and parallel communications, analog-to-digital converters, realtime clocks, and flash memory.
Engineers, inventors, experimenters, students, and device designers in general deal with microcontrollers on an everyday basis. In fact, interest in microcontrollers is not limited to electrical, electronic, and computer engineers. Mechanical and automotive engineers, among many others, often design devices or components that contain microcontrollers. The system that controls the hatch of a ballistic missile silo and the one that operates the doglike toy that barks and rolls on its back, both contain microcontrollers.
The Microchip PIC
Microcontrollers include an enormous array of models and variations of generaland special-purpose devices. Discussing all of them in a single volume would have forced a superficial scope. Even the products of a single manufacturer can have a mind-bog-
XV
XVI |
Preface |
gling variety, which sometimes include hundreds of different MCU models in a half-dozen families, all with very different applications and features.
For this reason we have focused the book on a single type of microcontroller: the M i c r o c h i p P I C . N o t o n l y a r e t h e P I C t h e m o s t u s e d a n d b e s t k n o w n microcontrollers, they are also the best supported. In fact, PIC system design and programming has become a powerful specialization with a large number of professional and amateur specialists. There are hundreds of WEB sites devoted to PIC-re- lated topics. An entire cottage industry of PIC software and hardware has flourished around this technology.
For practical reasons we have limited the book's scope to 8-bit PICs. In fact, the book concentrates on a particular type of 8-bit PIC known as the mid-range family. We have chosen this approach partly because of space limitations and partly due to the fact that 16and 32-bit microcontrollers (sometimes called external memory microcontrollers) are more related to microprocessor technology than to the topic at hand.
The Book's Design
The book is intended as a resource kit for PIC microcontroller programming. But programming microcontrollers is a different paradigm from microprocessor programming. PIC programming requires a set of skills and a knowledge base quite different from the one needed by a computer programmer. The reason is that the designer/programmer is responsible for the entire system. A typical embedded system has no DOS, Windows, or UNIX software to handle the operational and housekeeping chores. Thus, the PIC programmer provides all the functionality needed by the application with very little assistance from other programs. This makes the microcontroller programmer an application developer, a system's programmer, and an input/output specialist, all at the same time.
For these reasons, the microcontroller programmer must be familiar with a host of computer science topics, including low-level data representations, binary arithmetic, computer organization, input/output programming, concurrency and scheduling, memory management, timing operations, and system functions. At the same time, he or she must be quite conversant with digital electronics and circuit design since the object of the program is a hardware device.
In the first six chapters of the book we have attempted to provide the necessary background both in digital electronics and in computer science. Chapters 7, 8, and 9 are an overview of PIC architecture and programming tools. The remainder of the book deals with programming the various functions, modules, and devices. The appendices contain supplementary materials and expand the coding contained in the text. Readers familiar with electronics and circuit design can skip over Chapters 1, 5, and 6. Those well versed in computer science can do the same with Chapters 2, 3, and 4.
Mapleton, Minnesota |
Julio Sanchez |
June 28, 2006 |
Maria P. Canton |
Preface |
XVII |
Additional Material
Additional material is available from the CRC Web site:
www.crcpress.com
Under the menu Electronic Products (located on the left side of the screen), click on Downloads & Updates. A list of books in alphabetical order with Web downloads will appear. Locate this book by a search, or scroll down to it. After clicking on the book title, a brief summary of the book will appear. Go to the bottom of this screen and click on the hyperlinked “Download” that is in a zip file.
