did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

did-you-know? rent-now

Amazon no longer offers textbook rentals. We do!

We're the #1 textbook rental company. Let us show you why.

9781401839673

PIC Microcontroller An Introduction to Software & Hardware Interfacing

by ;
  • ISBN13:

    9781401839673

  • ISBN10:

    1401839673

  • Edition: 1st
  • Format: Hardcover
  • Copyright: 2004-07-01
  • Publisher: Cengage Learning

Note: Supplemental materials are not guaranteed with Rental or Used book purchases.

Purchase Benefits

  • Free Shipping Icon Free Shipping On Orders Over $35!
    Your order must be $35 or more to qualify for free economy shipping. Bulk sales, PO's, Marketplace items, eBooks and apparel do not qualify for this offer.
  • eCampus.com Logo Get Rewarded for Ordering Your Textbooks! Enroll Now
List Price: $343.99 Save up to $82.56
  • Rent Book $261.43
    Add to Cart Free Shipping Icon Free Shipping

    TERM
    PRICE
    DUE
    USUALLY SHIPS IN 24-48 HOURS
    *This item is part of an exclusive publisher rental program and requires an additional convenience fee. This fee will be reflected in the shopping cart.

Supplemental Materials

What is included with this book?

Summary

This book presents a thorough introduction to the Microchip PIC? microcontroller family, including all of the PIC programming and interfacing for all the peripheral functions. A step-by-step approach to PIC assembly language programming is presented, with tutorials that demonstrate how to use such inherent development tools such as the Integrated Development Environment MPLAB, PIC18 C compiler, the ICD2 in-circuit debugger, and several demo boards. Comprehensive coverage spans the topics of interrupts, timer functions, parallel I/O ports, various serial communications such as USART, SPI, I2C, CAN, A/D converters, and external memory expansion.

Table of Contents

Preface xxi
Introduction to the PIC18 Microcontroller
1(36)
Objectives
1(1)
What Is a Computer?
2(4)
The Processor
2(1)
The Microprocessor
3(1)
Microcontrollers
4(1)
Memory
4(2)
The Computer Software
6(2)
Assembly Language
6(1)
High-Level Languages
7(1)
Overview of the PIC18 MCU
8(5)
The PIC18 Memory Organization
13(4)
Separation of Data Memory and Program Memory
13(1)
PIC18 Data Memory
14(1)
EEPROM Data Memory
15(1)
Program Memory Organization
15(2)
The PIC18 CPU Registers
17(2)
The PIC18 Pipelining
19(1)
PIC18 Instruction Format
20(2)
Addressing Modes
22(4)
Register Direct
22(1)
Immediate Mode
23(1)
Inherent Mode
23(1)
Indirect Mode
23(2)
Bit-Direct Addressing Mode
25(1)
A Sample of PIC18 Instructions
26(3)
Data Movement Instructions
26(1)
ADD Instructions
27(2)
SUB Instructions
29(1)
Overview of the 8-Bit MCU Market
29(4)
CISC versus RISC
30(1)
Major 8-Bit MCUs
31(1)
Motorola 8-Bit MCUs
32(1)
Intel 8051/8052 Variants
32(1)
The Atmel AVR
33(1)
Summary
33(2)
Exercises
35(2)
PIC18 Assembly Language Programming
37(52)
Objectives
37(1)
Introduction
38(1)
Assembly Language Program Structure
38(2)
The Label Fields
38(1)
The Mnemonic Field
39(1)
The Operand Field
39(1)
The Comment Field
39(1)
Assembler Directives
40(13)
Control Directives
40(4)
Data Directives
44(3)
Macro Directives
47(1)
Listing Directives
48(2)
Object File Directives
50(3)
Representing the Program Logic
53(2)
A Template for Writing Assembly Programs
55(1)
Case Issue
56(1)
Writing Programs to Perform Arithmetic Computations
56(10)
Perform Addition Operations
56(2)
Perform Subtraction Operations
58(2)
Binary Coded Decimal Addition
60(3)
Multiplication
63(3)
Program Loops
66(9)
Program Loop Constructs
66(2)
Changing the Program Counter
68(7)
Reading and Writing Data in Program Memory
75(3)
Logic Instructions
78(2)
Using Program Loop to Create Time Delays
80(2)
Rotate Instructions
82(3)
Using Rotate Instructions to Perform Multiplications and Divisions
85(1)
Summary
86(1)
Exercises
87(2)
PIC18 Development Tools
89(36)
Objectives
89(1)
Development Tools
90(1)
Software Tools
90(1)
Text Editors
90(1)
Cross Assemblers and Cross Compilers
90(1)
Simulator
90(1)
Source-Level Debugger
91(1)
Integrated Development Environment
91(1)
Hardware Tools
91(4)
The Nature of Debugging Activities
91(1)
ICE
92(1)
Device Programmer
93(1)
In-Circuit-Debugger II
94(1)
Demo Boards
95(1)
Using MPLAB IDE
95(7)
Getting Started with MPLAB IDE
96(1)
Creating a Simple Project
97(3)
Entering Source Code
100(1)
Adding Source Files to the Project
101(1)
Building the Project
102(1)
Debugging the Project
102(1)
Using the MPLAB SIM in Debugging PIC18 Applications
102(9)
Setting Up the Simulator
103(1)
Running Code under MPLAB SIM
103(2)
Viewing Variables
105(1)
Using Watch Window to View Variables
105(1)
Setting Breakpoints
106(2)
Tracing Code
108(2)
Advanced Simulator Options
110(1)
Using the MPLAB ICD 2
111(5)
ICD2 Settings
112(4)
Demo Boards from Shuan-Shizu Enterprise
116(4)
SSE452 Demo Board
116(2)
SSE8720 Demo Board
118(1)
SSE8680 Demo Board
119(1)
Debug Monitor
120(1)
Summary
120(1)
Lab Exercises and Assignments
121(4)
Advanced Assembly Programming
125(58)
Objectives
125(1)
Introduction
126(1)
Signed Arithmetic
126(5)
Signed 8-Bit Multiplication
126(2)
Signed 16-Bit Multiplication
128(3)
Unsigned Divide Operation
131(2)
Signed Divide Operation
133(4)
The Stack
137(2)
Stack Operations
138(1)
Subroutines
139(3)
Instructions for Supporting Subroutine Calls
140(1)
Return Address Stack
141(1)
Top-of-Stack Access
141(1)
Return Address Stack Pointer (STKPTR)
141(1)
Fast Register Stack
141(1)
Table Lookup Instruction
142(1)
Issues Related to Subroutine Calls
142(11)
The Stack Frame
144(1)
Accessing Locations in the Stack Frame
144(9)
String Processing
153(13)
More Examples on Subroutine Calls
166(11)
Square Root Computation
171(3)
Finding Prime Numbers
174(3)
Summary
177(1)
Exercises
177(2)
Lab Exercises and Assignments
179(4)
A Tutorial to the C Language and the Use of the C Compiler
183(60)
Objectives
183(1)
Introduction to C
184(1)
Types, Operators, and Expressions
185(3)
Data Types
185(1)
Variable Declarations
185(1)
Constants
185(1)
Arithmetic Operators
186(1)
Bitwise Operators
186(1)
Relational and Logical Operators
187(1)
Precedence of Operators
188(1)
Control Flow
188(4)
If Statement
188(1)
If-Else Statement
189(1)
Multiway Conditional Statement
189(1)
Switch Statement
190(1)
For-Loop Statement
190(1)
While Statement
191(1)
Do-While Statement
191(1)
GOTO Statement
191(1)
Input and Output
192(1)
Functions and Program Structure
193(3)
Pointers, Arrays, Structures, and Unions
196(5)
Pointers and Addresses
196(1)
Arrays
197(1)
Pointers and Arrays
197(1)
Passing Arrays to a Function
198(1)
Initializing Arrays
199(1)
Structures
199(1)
Unions
200(1)
Miscellaneous Items
201(2)
Automatic/External/Static/Volatile
201(1)
Scope Rules
202(1)
Introduction to Project Build Process for the Microchip PIC18 Compiler
203(1)
The MPLINK Linker
204(5)
A Tutorial on Using the MCC18 Compiler
209(7)
Creating a New Project
210(2)
Setting Build Options
212(1)
Add Source Files to Project
212(2)
Building the Project
214(1)
Choosing Debug Tool
214(1)
Build the Project
214(1)
Checking the ICD2 Settings
214(1)
Program the Target Device
215(1)
Running the Program
215(1)
C Language Implementation in the MCC18 Compiler
216(3)
Data Types and Limits
216(1)
Storage Classes
217(1)
Storage Qualifiers
218(1)
Overlay
218(1)
ANSI/ISO Divergences
219(2)
Integer Promotions
219(1)
Numeric Constants
220(1)
String Constants
220(1)
Anonymous Structures
221(1)
Inline Assembly
221(1)
Bit Field Manipulation in C Language
222(3)
Processor-Specific Header Files
223(2)
Processor-Specific Register Definition Files
225(1)
The #pragma Statement
225(1)
#pragma Section Type
225(1)
Mixing C and Assembly
226(6)
Calling Conventions
226(2)
Return Values
228(1)
Calling C Routines from an Assembly Program
228(1)
Calling Assembly Functions from a C Program
229(1)
Referencing C Variables in an Assembly Function
230(1)
Referencing Assembly Variables in a C Function
231(1)
Startup Code
231(1)
MPLAB C18 Library Functions
232(5)
Processor-Specific Libraries
232(1)
Processor-Independent Library
232(1)
Character Classification Functions
232(1)
Data Conversion Library Functions
233(1)
Memory and String Manipulation Functions
234(1)
Delay Functions
235(2)
Using the Hi-Tech C18 Compiler
237(1)
Summary
238(1)
Exercises
239(1)
Lab Exercises and Assignments
240(3)
Interrupts, Resets, and Configuration
243(32)
Objectives
243(1)
Basics of Interrupts
244(4)
What Is an Interrupt?
244(1)
Why Interrupts?
245(1)
Interrupt Maskability
245(1)
Interrupt Priority
246(1)
Interrupt Service
246(1)
Interrupt Vector
246(1)
Interrupt Programming
247(1)
Interrupt Overhead
248(1)
Resets
248(1)
The PIC18 Interrupts
249(12)
PIC18 Interrupt Priority
249(1)
Registers Related to Interrupts
249(1)
RCON Register
249(1)
Interrupt Control Registers (Intcon, Intcon2, Intcon3)
250(3)
PIR1 PIR3 Registers
253(2)
PIE1 PIE3 Registers
255(3)
Interrupt Priority Registers (IPR1 IPR3)
258(3)
PIC18 Interrupt Operation
261(3)
PIC18 Interrupt without Setting Priority
262(1)
PIC18 Interrupt with Priority Enabled
262(1)
INT Pin Interrupts
263(1)
Port B Pins Input Change
263(1)
TMRO Overflow Interrupt
263(1)
Peripheral Interrupts
263(1)
PIC18 Interrupt Programming
264(6)
Interrupt Programming in Assembly Language
264(3)
Interrupt Programming in C Language
267(2)
Context Saving during Interrupts
269(1)
The PIC18 Resets
270(1)
Power-On Reset
271(1)
Power-Up Timer
271(1)
Oscillator Start-Up Timer
271(1)
Brown-Out Reset
271(1)
The Reset Instruction
271(1)
Summary
271(2)
Exercises
273(1)
Lab Exercises and Assignments
273(2)
Parallel Ports
275(58)
Objectives
275(1)
Introduction
276(1)
I/O Addressing
277(1)
I/O Synchronization
277(4)
Synchronizing the CPU with the Interface Chip
278(1)
Synchronizing the Interface Chip with I/O Devices
279(2)
Overview of the PIC18 Parallel Ports
281(6)
Port A
283(1)
Port B
284(1)
Port C
285(1)
Port D
285(1)
Port E and Port F
286(1)
Port G
286(1)
Port H and Port J
286(1)
Port K
287(1)
Interfacing with Simple Output Devices
287(7)
Interfacing with LEDs
287(1)
Interfacing with Seven-Segment Displays
288(5)
Liquid Crystal Display
293(1)
The HD44780 LCD Controller
294(18)
Display Data RAM
296(1)
Character Generator ROM
297(1)
Character Generator RAM
297(1)
Registers
297(1)
Instruction Description
298(1)
Interfacing the HD44780 to the PIC18 Microcontroller
299(13)
Interfacing with DIP Switches
312(1)
Interfacing with a Keypad
313(9)
Keypad Scanning
313(1)
Keypad Debouncing
314(8)
Interfacing with a D/A Converter
322(4)
The MAX5102 DAC
322(2)
Interfacing the MAX5102 with the PIC18 Microcontroller
324(2)
Parallel Slave Port
326(4)
Summary
330(1)
Exercises
330(2)
Lab Exercises and Assignments
332(1)
Timers and CCP Modules
333(74)
Objectives
333(1)
Overview of PIC18 Timer Functions
334(1)
Timers
334(15)
Timers0
335(3)
Timer1
338(5)
Timer2
343(2)
Timer3
345(1)
Timer4
346(1)
C Library Functions for Timers
347(2)
Capture/Compare/PWM Modules
349(2)
CCP Module Configuration
350(1)
CCP in Capture Mode
351(10)
Capture Operation
352(1)
Microchip C Library Functions for CCP in Capture Mode
352(1)
Applications of Capture Mode
353(8)
CCP in Compare Mode
361(12)
Compare Mode Operation
361(1)
Applications of CCP in Compare Mode
362(11)
CCP in PWM Mode
373(12)
PWM C Library Functions
376(1)
PWM Applications
377(3)
DC Motor Control
380(5)
Enhanced CCP Module
385(16)
ECCP Pins
385(1)
ECCP Registers
385(2)
Enhanced PWM Mode
387(14)
Summary
401(2)
Exercises
403(1)
Lab Exercises and Assignments
404(3)
Addressable Universal Synchronous Asynchronous Receiver Transceiver
407(38)
Objectives
407(1)
Overview of Serial Communication
408(1)
The EIA232 Standard
408(10)
Electrical Specifications
409(1)
EIA232E Functional Specifications
409(3)
EIA232E Mechanical Specifications
412(1)
EIA232E Procedural Specifications
413(3)
Data Format
416(1)
Data Transmission Errors
417(1)
Null-Modem Connection
417(1)
The PIC18 Serial Communication Interface
418(22)
USART-Related Registers
418(3)
USART Asynchronous Mode
421(5)
Flow Control of USART in Asynchronous Mode
426(1)
C Library Functions for USART
427(3)
Interface Asynchronous Mode USART with EIA232
430(2)
USART Synchronous Master Mode
432(2)
USART Synchronous Slave Mode
434(1)
Applications of USART Synchronous Mode
434(6)
Enhanced USART
440(1)
Summary
441(1)
Exercises
442(1)
Lab Exercises and Assignments
443(2)
Serial Peripheral Interface
445(58)
Objectives
445(1)
Introduction
446(1)
SPI Mode
446(9)
MSSP Registers
447(2)
SPI Operation
449(1)
Configuration of MSSP for SPI Mode
449(4)
SPI Data Transfer
453(1)
SPI Circuit Connection
453(2)
SPI C Library Functions
455(1)
Applications of SPI
456(1)
Interfacing with the 74HC595
456(6)
Operation of the 74HC595
457(5)
MAX7221 Seven-Segment Display Driver
462(12)
Signal Pins
462(1)
MAX7221 Functioning
463(5)
Choosing the Value for RSET
468(6)
Digital Temperature Sensor TC72
474(7)
Functioning of TC72
475(1)
Temperature Data Format
475(1)
Serial Bus Interface
476(2)
Internal Register Structure
478(3)
The DS1306 Alarm Real-Time Clock
481(17)
Signal Descriptions
482(1)
RTC Registers
483(4)
Serial Interface of DS1306
487(1)
Power Supply Configurations
488(1)
Applications
488(10)
Summary
498(1)
Exercises
499(3)
Lab Exercises and Assignments
502(1)
Interintegrated Circuit Interface
503(60)
Objectives
503(1)
The I2C Protocol
504(11)
Characteristics of I2C Protocol
504(1)
I2C Signal Levels
504(1)
I2C Data Transfer Signal Components
505(2)
Synchronization
507(1)
Arbitration
508(1)
Data Transfer Format
509(1)
7-Bit Addressing
510(2)
10-Bit Addressing
512(3)
PIC18 MSSP Module in I2C Mode
515(1)
Registers for I2C Operation
515(4)
The SSPCON1 Register
515(1)
The SSPCON2 Register
516(2)
The SSPSTAT Register (I2C Mode)
518(1)
MSSP Address Register
519(1)
The PIC18 I2C Master Mode
519(8)
Master Mode Operation
519(3)
Master Mode Transmit Sequence
522(1)
Baud Rate Generator
522(2)
Start Condition Timing
524(1)
Repeated Start Condition Timing
524(1)
Master Mode Transmission
525(1)
Master Mode Reception
526(1)
Acknowledge Sequence Timing
526(1)
Stop Condition Timing
527(1)
PIC18 I2C Slave Mode
527(4)
Slave Addressing
528(1)
Reception in Slave Mode
528(1)
Transmission in Slave Mode
529(1)
Clock Synchronization and the CKP Bit
529(1)
General Call Address Support
529(1)
Clock Stretching
530(1)
Multimaster Mode
531(1)
Microchip C18 Library Functions for I2C
532(2)
Interfacing the Digital Thermometer and Thermostat DS1631A with I2C
534(14)
Pin Assignment
534(1)
Functional Description
535(1)
DS1631A Registers
535(2)
The DS1631A Operation
537(1)
DS1631A Command Set
538(1)
I2C Communication with DS1631A
538(10)
Interfacing the Serial EEPROM 24LC08B with I2C
548(11)
Pin Assignment and Block Diagram
548(1)
Device Addressing
549(1)
Write Operation
549(1)
Acknowledge Polling
549(1)
Read Operation
550(1)
Circuit Connection between the I2C Master and 24LC08B
551(6)
C Library Functions for I2C EEPROM
557(2)
Summary
559(1)
Exercises
560(1)
Lab Exercises and Assignments
561(2)
Analog-to-Digital Converter
563(44)
Objectives
563(1)
Basics of A/D Conversion
564(7)
A Data Acquisition System
564(1)
Analog Voltage and Digital Code Characterstic
564(2)
A/D Conversion Algorithms
566(2)
Optimal Voltage Range for A/D Conversion
568(1)
Scaling Circuit
569(1)
Voltage Translation Circuit
569(2)
The PIC18 A/D Converter
571(10)
Registers Associated with A/D Converter
571(6)
A/D Acquisition Requirements
577(1)
Selecting the A/D Conversion Clock
578(1)
A/D Conversion Process
579(1)
Use of the CCP2 Register
580(1)
Procedure for Performing A/D Conversion
581(2)
Microchip A/D Converter C Library Functions
583(5)
Using the Temperature Sensor TC1047A
588(7)
Using the IH-3606 Humidity Sensor
595(3)
Measuring Barometric Pressure
598(3)
Summary
601(1)
Exercises
602(2)
Lab Exercises and Assignments
604(3)
Controller Area Network
607(82)
Objectives
607(1)
Overview of Controller Area Network
608(2)
Layered Approach in CAN
608(1)
General Characteristics of CAN
608(2)
CAN Messages
610(7)
Data Frame
610(3)
Remote Frame
613(1)
Error Frame
614(1)
Overload Frame
614(1)
Interframe Space
615(1)
Message Filtering
616(1)
Message Validation
616(1)
Bit Stream Encoding
616(1)
Error Handling
617(1)
Bit Error
617(1)
Stuff Error
617(1)
CRC Error
617(1)
Form Error
617(1)
Acknowledgment Error
617(1)
Error Signaling
617(1)
Fault Confinement
617(2)
CAN Node Status
617(1)
Error Counts
618(1)
CAN Message Bit Timing
619(1)
Nominal Bit Time
619(1)
Length of Time Segments
620(1)
Synchronization Issue
620(1)
Resynchronization Jump Width
620(1)
Phase Error of an Edge
621(1)
Synchronization Rules
621(1)
PIC18 CAN Module
621(1)
CAN Modes of Operation
622(4)
Configuration Mode
625(1)
Disable Mode
625(1)
Normal Mode
626(1)
Listen-Only Mode
626(1)
Loopback Mode
626(1)
Error Recognition Mode
626(1)
CAN Module Registers
626(3)
CAN Module Functional Modes
629(1)
Mode 0---Legacy Mode
629(1)
Mode 1---Enhanced Legacy Mode
629(1)
Mode 2---Enhanced FIFO Mode
629(1)
CAN Message Buffers
630(12)
Dedicated Transmit Buffers
630(3)
Dedicated Receive Buffers
633(1)
Programmable Transmit/Receive Buffers
634(8)
Programmable Auto RTR Buffers
642(1)
CAN Message Transmission
642(2)
Aborting Transmission
644(1)
Transmit Priority
644(1)
Message Reception
644(3)
Receive Modes
645(1)
Receive Priority
645(1)
Enhanced FIFO Mode
645(1)
Time Stamping
646(1)
Message Acceptance Filters and Masks
647(5)
Baud Rate Setting and Timing Parameters
652(3)
Error Detection and Interrupts
655(7)
Error States
656(1)
Error Modes and Error Counters
656(1)
CAN Interrupts
656(4)
Efficient Handling of CAN Interrupts
660(2)
CAN Module I/O Control Register
662(1)
Physical CAN Bus Connection
662(9)
The MCP2551 CAN Transceiver
663(3)
Interfacing the MCP2551 to the PIC18F CAN Devices
666(1)
Setting the CAN Timing Parameters
667(4)
CAN Programming
671(14)
Summary
685(1)
Exercises
686(1)
Lab Exercises and Assignments
687(2)
Internal and External Memory Programming and Expansion
689(52)
Objectives
689(1)
Overview of the PIC18 Memory System
690(1)
On-Chip Flash Program Memory
690(10)
Control Registers of Program Flash Memory
691(1)
Reading the Flash Program Memory
692(1)
Erasing Flash Program Memory
692(1)
Writing to Flash Program Memory
693(7)
Data EEPROM Memory
700(2)
EEADR and EEADRH Register
701(1)
Reading the Data EEPROM Memory
701(1)
Writing to the Data EEPROM Memory
701(1)
PIC18 External Memory Interface
702(15)
PIC18 Program Memory Modes
702(1)
PIC18 External Memory Pins
703(1)
Waveforms of Bus Signals
704(2)
Bus Transactions
706(2)
Bus Multiplexing
708(1)
PIC18F8XXX External Memory Functions
708(4)
16-Bit EMI Operating Modes
712(4)
Wait States
716(1)
Issues Related to Adding External Memory
717(2)
Memory Space Assignment
717(1)
Address Decoder Design
718(1)
Timing Verification
718(1)
Memory Devices
719(11)
The CY7C1019
719(4)
The AT28C010 EEPROM
723(7)
Example of External Memory Expansion for the PIC18 Microcontroller
730(8)
Memory Space Assignment
730(1)
Address Latch
730(3)
Address Decoder Design
733(1)
PIC18F8680 Timing Parameter Values at 25 MHz
733(1)
Example PIC18F8680 Demo Board Memory System Diagram
733(5)
Summary
738(1)
Exercises
739(1)
Lab Exercises and Assignments
739(2)
System Configuration and Protection
741(22)
Objectives
741(1)
Introduction
742(1)
Configuration Registers
742(14)
The CONFIG1H Register
742(1)
The CONFIG2L Register
743(1)
The CONFIG2H Register
744(1)
The CONFIG3L Register
745(1)
The CONFIG3H Register
745(1)
The CONFIG4L Register
746(1)
The CONFIG5L Register
747(2)
The CONFIG5H Register
749(1)
The CONFIG6L Register
749(2)
The CONFIG6H Register
751(1)
The CONFIG7L Register
751(2)
The CONFIG7H Register
753(1)
The Device ID Registers
753(1)
Programming the Configuration Bits
754(2)
Watchdog Timer
756(1)
Power-Down Mode (Sleep)
757(1)
Program Code Protection
758(1)
Program Memory Code Protection
758(1)
Data EEPROM Code Protection
759(1)
Configuration Register Protection
759(1)
ID Locations
759(1)
ICSP
759(1)
In-Circuit Debugger
759(1)
Low Voltage ICSP Programming
760(1)
Summary
760(1)
Exercises
760(3)
Glossary 763(10)
Index 773

Supplemental Materials

What is included with this book?

The New copy of this book will include any supplemental materials advertised. Please check the title of the book to determine if it should include any access cards, study guides, lab manuals, CDs, etc.

The Used, Rental and eBook copies of this book are not guaranteed to include any supplemental materials. Typically, only the book itself is included. This is true even if the title states it includes any access cards, study guides, lab manuals, CDs, etc.

Rewards Program