| This book on PIC Microcontroller
is intended primarily for undergraduate students in technology
and engineering curriculum and also for practicing engineers
who are working in embedded systems.
It is a comprehensive treatment of the microcontroller
fundamentals that includes architecture,
assembly language programming, and applications of microcontrollers
in embedded systems. Microchip PIC18F microcontroller families are used in the illustrations. This
book assumes a course in digital logic as a prerequisite;
however, it does not assume any background in programming.
The purpose of this book on PIC Microcontroller
is threefold: one is to teach the basic principles underlying
the microprocessor/microcontroller and its applications;
the second is to teach assembly language; and the third
is to expose students to the latest technology that
is used in industry. These three objectives can be accomplished
by using the PIC18F microcontroller
as an illustration. This book is aimed at two levels: an introductory course in microcontrollers and
an advanced course in designing microcontroller-based
systems.
Features of the Text:
1. Comprehensive Integrated Approach to Hardware
and Software. The book is divided in three
sections and the content is comprehensive: basic concepts
in hardware, assembly language, and integration of hardware
and software in interfacing peripherals and designing
an embedded system.
2. Organization Appropriate to Teaching
Most microprocessor courses are laboratory oriented.
Initially, this textbook covers enough hardware architecture
essentials to prepare students to write programs; students
will be able to write simple programs beginning with
Chapter 2. When students are able to write programs,
the textbook returns to hardware topics.
3. Step-By-Step Approach for Software Students are exposed to programming in a systematic
way. This is the area where students need assistance.
Often students enter this type of course with no programming
background. The text has been designed to supply that
needed support. The programming section includes numerous
illustrative examples. These examples begin with a problem
statement, provide the analysis of the problem, illustrate
the program, and explain the programming steps. Chapters
5 through 8 differ from any available texts, and are
the major strength of the book. Instructions are explained
in detail through the use of examples, not just listed
from the Microchip manual. Examples and explanations
of instructions enhance students' understanding of programming.
An instruction set with full explanation is essential
in writing programs.
4. Text is laboratory oriented This feature also reinforces the integral aspect of
software with hardware. Chapters 5 through 8 can be
used for laboratory experiences. The section includes
illustrative programs that can be used to verify programming
concepts on a simulator or single-board demo board.
5. In-Depth Treatment of I/O Interfacing. Chapters 9 through 13 are devoted to I/O interfacing
and various peripherals. Illustrative examples in these
chapters can be used in laboratory to perform hardware
experiments.
6. Synthesis of the Concepts through Project Design Chapter 14 is concerned with the design of a temperature
control and display project that synthesizes all the
concepts discussed in earlier chapters.
7. Appendices include details of software for
laboratory experiments. MPLAB IDE, an integrated software package that
includes an assembler, a debugger, and a simulation
program, is available from Microchip. Students can use
the source code included on the CD in laboratory experiments.
TABLE OF CONTENTS
Chapter 1 Microprocessor and Microcontroller
Fundamentals
1.1 Embedded Systems and Microcontrollers
1.2 Microprocessor-Based Systems: Internal View with System Bus
1.3 Software: From Machine to High-Level Languages 1
1.4 Data Format
1.5 Microprocessor (MPU)- and Microcontroller (MCU)-Based
Systems
1.6 Historical Perspective and Look Ahead
Summary
Questions
Chapter 2 Microcontroller Architecture—PIC18F
Family
2.1 PIC18F Microcontroller Families
2.2 Processes of Data Transfer between a Microcontroller and Outside Peripherals
2.3 Support Devices
2.4 Microchip PIC Family of Devices
2.5 PIC18F Instructions and Assembly Language
2.6 Illustration: Displaying a Byte at an I/O Port of PIC18F452 Microcontroller
2.7 Embedded System: Temperature and Time Display
Summary
Questions, Assignments, and Simulation Exercises
Simulation Exercises Using PIC18 Simulator IDE
Chapter 3 PIC18F Programming Model and Its Instruction Set
3.1 PIC18F Programming Model
3.2 Introduction to PIC18 Instruction Set
3.3 Instruction Format
3.4 Illustration: Addition
Summary
Questions and Assignments
Simulation Exercises
Chapter 4 Programming and Problem Solving
4.1 Approach to Problem Solving with Programming
4.2 Illustrative Program: Addition with Carry Check
4.3 Integrated Development Environment (IDE)
4.4 Illustrative Program: Addition with Carry Check
4.5 Assembling, Debugging, and Executing a Program Using MPLAB IDE
Summary
Questions and Assignments
Simulation Exercises
vii
Chapter 5 Introduction to Data Copy (Move),Arithmetic, and Branch Instructions 5.1 Data Copy (Move) and Set/Clear Operations
5.2 Arithmetic Operations
5.3 Redirection of Program Execution (Branch and Skip
Operations)
5.4 Generating Time Delays
5.5 Illustrative Program: Generating Waveforms
5.6 Illustrative Program: Copying a Block of Data from
Program Memory to Data Registers
5.7 Illustrative Program: Addition of Data Bytes
5.8 Illustrative Program: Searching for Specific Characters
in a Data Set
Summary
Questions and Assignments
Simulation Exercises
Chapter 6 Introduction to Logic, Bit Manipulation,
and Multiply-Divide Operations
6.1 Logic Operations
6.2 Bit Operations
6.3 Multiply and Divide Operations
6.4 Illustrative Program: Finding the Highest Temperature
in a Data String
6.5 Illustrative Program: Finding an Average Temperature
of Data Readings
Summary
Questions and Assignments
Simulation Exercises
Chapter 7 Stack and Subroutines
7.1 Stack
7.2 Subroutine
7.3 Macros and Software Stack
7.4 Illustrative Program: Copying and Adding Data Bytes
7.5 Illustrative Program: Calculating Average Temperature
Summary
Questions and Assignments
Simulation Exercises
Chapter 8 Application Programs and Software
Design 8.1 BCD to Binary Conversion
8.2 Binary to BCD Conversion
8.3 ASCII Code to Binary Conversion
8.4 Binary to ASCII Code Conversion
8.5 Illustrative Program: Multiplication of 16-Bit
Numbers
8.6 Illustrative Program: Division of Two 8-Bit Unsigned
Numbers
8.7 Software Design
Summary
Questions and Assignments
Simulation and Troubleshooting Exercises
Chapter 9 Input/Output (I/O) Ports and Interfacing 9.1 Basic Concepts is I/O Interfacing and PIC18 I/O
Ports
9.2 Interfacing Output Peripherals
9.3 Illustration: Displaying BCD Counter at Seven-Segment
LEDs
9.4 Interfacing Input Peripherals
9.5 Illustration: Interfacing Push-Button Keys
9.6 Illustration: Interfacing an LCD (Liquid Crystal
Display)
9.7 Illustration: Interfacing a Matrix Keyboard
9.8 Illustration: Interfacing Seven Segment LEDs –
Time Multiplex Scanning Technique
viii
Summary
Questions and Assignment
Chapter 10 Interrupts 10.1 Basic Concepts in Interrupts
10.2 PIC18 Interrupts
10.3 Illustration: Implementation of Interrupt Process
in PIC18 Microcontroller
Summary
Questions and Assignments
Chapter 11 Timers 11.1 Basic Concepts in Counters and Timers
11.2 PIC18 Timers
11.3 CCP (Capture, Compare, and PWM) Modules
11.4 Illustration: Generating a Periodic Waveform Using
an Interrupt
11.5 Illustration: Designing a 12-Hour Clock
Summary
Questions and Assignments
Simulation Exercises
Chapter 12 Data Converters 12.1 Data Converters: Basic Concepts
12.2 PIC18F4520 Analog-to-Digital (A/D) Converter Module
12.3 Illustration: Interfacing a Temperature Sensor
to the A/D Converter Module
12.4 Digital to Analog (D/A, DAC, or D-to-A) Conversion
12.5 Illustration: Generating a Ramp Waveform Using
a D/A Converter
Summary
Questions and Assignments
Simulation Exercises
Chapter 13 Serial I/O 401 13.1 Basic Concepts in Serial Communication
13.2 EIA-232 and PIC18 Serial Communication Module
USART
13.3 Serial Peripheral Interface (SPI)
13.4 The Inter-Integrated Circuit (I2C) Protocol
13.5 Illustration: Interfacing Serial EEPROM to the
PIC18 MSSP Module in the SPI Mode
13.6 Illustration: Interfacing Serial EEPROM to the
PIC18 MSSP Module in the I2C Mode
Summary
Questions and Assignments
Simulation Exercises
Chapter 14 Designing Embedded Systems 14.1 Features of Embedded Systems
14.2 Designing Embedded Systems
14.3 TTMS Project Design: Hardware
14.4 TTMS Project Design – Software
14.5 Special Features and Configuration Registers
Summary
Questions and Assignments
Simulation Exercises
Ix
Appendices A PIC18FXXX/XXXX Instruction Set
B In-Circuit Emulator (ICE), In-Circuit
Debugger (ICD), and MicrochipMPLAB® ICD 2
C Operational Amplifiers and Signal
Conditioning Circuits
D Number Systems and Hex Arithmetic
E American Standard Code for Information
Interchange: ASCII Codes
F PIC18 Simulator IDE
Index
|