Preface |
|
xiii | |
Credits |
|
xvii | |
|
1 Introduction To Microcontrollers |
|
|
1 | (16) |
|
|
3 | (4) |
|
1.2 Microcontroller Data Types |
|
|
7 | (4) |
|
1.2.1 Unsigned and Signed Binary Numbers |
|
|
7 | (3) |
|
1.2.2 ASCII and EBCDIC Codes |
|
|
10 | (1) |
|
1.2.3 Unpacked and Packed Binary-Coded-Decimal Numbers |
|
|
10 | (1) |
|
1.3 Evolution of the Microcontroller |
|
|
11 | (3) |
|
|
14 | (3) |
|
|
17 | (20) |
|
2.1 Basic Blocks of a Microcomputer |
|
|
17 | (3) |
|
|
18 | (1) |
|
|
19 | (1) |
|
2.2 Microcontroller architectures |
|
|
20 | (1) |
|
2.3 Central Processing Unit (CPU) |
|
|
21 | (10) |
|
|
21 | (8) |
|
|
29 | (1) |
|
2.3.3 Arithmetic and Logic Unit (ALU) |
|
|
30 | (1) |
|
2.3.4 Simplified Explanation of Control Unit design |
|
|
30 | (1) |
|
2.4 Basic concept of pipelining |
|
|
31 | (2) |
|
|
33 | (1) |
|
2.6 Functional Representation of a Typical Microcontroller---The PIC 18F4321 |
|
|
34 | (3) |
|
|
36 | (1) |
|
3 Microcontroller Memory And Input/Output (I/O) |
|
|
37 | (22) |
|
3.1 Introduction to Microcontroller Memory |
|
|
37 | (8) |
|
|
38 | (2) |
|
3.1.2 READ and WRITE Timing Diagrams |
|
|
40 | (2) |
|
3.1.3 Main Memory Organization |
|
|
42 | (3) |
|
3.2 Microcontroller Input/Output (I/O) |
|
|
45 | (14) |
|
3.2.1 Overview of digital output circuits |
|
|
47 | (2) |
|
|
49 | (1) |
|
|
50 | (2) |
|
3.2.4 Unconditional and Conditional Programmed I/O |
|
|
52 | (1) |
|
|
53 | (3) |
|
|
56 | (3) |
|
|
59 | (34) |
|
4.1 Computer Programming Languages |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
60 | (14) |
|
4.3.1 Types of Assemblers |
|
|
61 | (1) |
|
4.3.2 Assembler Delimiters |
|
|
62 | (1) |
|
4.3.3 Specifying Numbers by Typical Assemblers |
|
|
63 | (1) |
|
4.3.4 Assembler Directives or Pseudoinstructions |
|
|
63 | (2) |
|
4.3.5 Assembly Language Instruction Formats |
|
|
65 | (2) |
|
4.3.6 Typical Instruction Set |
|
|
67 | (6) |
|
4.3.7 Typical Addressing Modes |
|
|
73 | (1) |
|
4.3.8 Subroutine Calls in Assembly Language |
|
|
74 | (1) |
|
|
74 | (2) |
|
4.5 Introduction to C Language |
|
|
76 | (12) |
|
|
78 | (1) |
|
4.5.2 Bit manipulation operators |
|
|
79 | (2) |
|
|
81 | (1) |
|
4.5.4 The if-else construct |
|
|
81 | (1) |
|
4.5.5 The switch construct |
|
|
82 | (1) |
|
4.5.6 The while construct |
|
|
83 | (1) |
|
|
84 | (1) |
|
4.5.8 The do-while construct |
|
|
85 | (1) |
|
4.5.9 Structures, and Unions |
|
|
85 | (1) |
|
|
86 | (2) |
|
|
88 | (1) |
|
|
88 | (1) |
|
4.6 Choosing a programming language |
|
|
88 | (1) |
|
|
89 | (4) |
|
|
90 | (3) |
|
5 PIC18F Architecture And Addressing Modes |
|
|
93 | (22) |
|
5.1 Basic features of the PIC18F family |
|
|
93 | (3) |
|
5.2 PIC18F Register Architecture |
|
|
96 | (4) |
|
5.3 PIC18F Memory Organization |
|
|
100 | (4) |
|
5.3.1 PIC18F Program Memory |
|
|
101 | (1) |
|
|
101 | (3) |
|
5.4 PIC18F Addressing Modes |
|
|
104 | (11) |
|
5.4.1 Literal or Immediate Addressing Mode |
|
|
104 | (1) |
|
5.4.2 Inherent or Implied Addressing Mode |
|
|
104 | (1) |
|
5.4.3 Direct or Absolute Addressing Mode |
|
|
104 | (1) |
|
5.4.4 Indirect Addressing Mode |
|
|
105 | (5) |
|
5.4.5 Relative Addressing Mode |
|
|
110 | (2) |
|
5.4.6 Bit Addressing Mode |
|
|
112 | (1) |
|
|
113 | (2) |
|
6 Assembly Language Programming With The PIC18F: PART 1 |
|
|
115 | (40) |
|
6.1 Introduction to the PIC18F MPLAB assembler |
|
|
115 | (5) |
|
6.2 PIC18F Instruction Format |
|
|
120 | (1) |
|
6.3 PIC18F Instruction Set |
|
|
121 | (34) |
|
6.3.1 Data Movement Instructions |
|
|
124 | (6) |
|
6.3.2 Arithmetic Instructions |
|
|
130 | (8) |
|
|
138 | (3) |
|
6.3.4 Rotate Instructions |
|
|
141 | (6) |
|
6.3.5 Bit Manipulation Instructions |
|
|
147 | (4) |
|
|
151 | (4) |
|
7 Assembly Language Programming With The PIC18F: PART 2 |
|
|
155 | (40) |
|
7.1 PIC18F Jump/Branch instructions |
|
|
155 | (2) |
|
7.2 PIC18F Test, Compare, and Skip instructions |
|
|
157 | (6) |
|
7.3 PIC18F Table Read/Write instructions |
|
|
163 | (5) |
|
7.4 PIC18F Subroutine instructions |
|
|
168 | (2) |
|
7.5 PIC18F System Control instructions |
|
|
170 | (1) |
|
7.6 PIC18F Hardware vs. Software stack |
|
|
171 | (7) |
|
7.7 Multiplication and Division algorithms |
|
|
178 | (6) |
|
7.7.1 Signed Multiplication algorithm |
|
|
178 | (2) |
|
7.7.2 Unsigned Division algorithm |
|
|
180 | (2) |
|
7.7.3 Signed Division algorithm |
|
|
182 | (2) |
|
7.8 Advanced Programming Examples |
|
|
184 | (4) |
|
|
188 | (7) |
|
|
191 | (4) |
|
8 PIC18F Programmed I/O Using Assembly & C |
|
|
195 | (36) |
|
8.1 PIC18F Pins and Signals |
|
|
195 | (13) |
|
|
196 | (6) |
|
|
202 | (3) |
|
8.1.3 High Voltage and Low Voltage Programming (HVP and LVP) |
|
|
205 | (1) |
|
8.1.4 "Pragma config" and "config" directives |
|
|
205 | (1) |
|
8.1.5 A simplified setup for the PIC18F4321 |
|
|
206 | (1) |
|
8.1.6 Downloading programs into the PIC18F4321 using the PICKit3 interface |
|
|
206 | (2) |
|
8.2 PIC18F4321 Programmed I/O |
|
|
208 | (23) |
|
8.2.1 I/O instructions in PIC18F assembly |
|
|
211 | (1) |
|
8.2.2 Configuring PIC18F4321 I/O ports using PIC18F assembly |
|
|
211 | (2) |
|
8.2.3 Configuring PIC 18F4321 I/O ports using C |
|
|
213 | (2) |
|
8.2.4 Interfacing LED's (Light Emitting Diodes) and Seven-segment displays |
|
|
215 | (1) |
|
8.2.5 Programmed I/O examples using PIC18F assembly |
|
|
216 | (4) |
|
8.2.6 Programmed I/O examples using C Language |
|
|
220 | (8) |
|
|
228 | (3) |
|
9 PIC18F Interrupt I/O, LCD, And Keyboard Interfacing |
|
|
231 | (42) |
|
9.1 Basics of Polled I/O vs. Interrupt I/O |
|
|
231 | (5) |
|
|
236 | (16) |
|
9.2.1 Interrupt Procedure |
|
|
236 | (2) |
|
9.2.2 PIC18F Interrupt Types |
|
|
238 | (1) |
|
9.2.3 Programming the PIC 18F External Interrupts |
|
|
238 | (5) |
|
9.2.4 Programming PIC18F external interrupts using assembly |
|
|
243 | (1) |
|
9.2.5 Programming PIC 18F external interrupts using C |
|
|
243 | (9) |
|
9.2.6 Accessing PIC18F on-chip peripheral devices using Polled I/O vs. Interrupt I/O |
|
|
252 | (1) |
|
9.3 PIC18F Interface to a typical LCD (Liquid Crystal Display) |
|
|
252 | (7) |
|
9.4 Interfacing PIC18F4321 to a hexadecimal keyboard and a seven-segment display |
|
|
259 | (14) |
|
9.4.1 Basics of Keyboard and Display Interface to a Microcontroller |
|
|
259 | (2) |
|
9.4.2 PIC18F4321 Interface to a Hexadecimal Keyboard and a Seven-Segment Display |
|
|
261 | (9) |
|
|
270 | (3) |
|
10 PIC18F Timers And Analog Interface |
|
|
273 | (48) |
|
|
273 | (28) |
|
|
275 | (8) |
|
|
283 | (6) |
|
|
289 | (4) |
|
|
293 | (8) |
|
|
301 | (20) |
|
10.2.1 PIC18F on-chip ADC (A/D Converter) |
|
|
302 | (13) |
|
10.2.2 Interfacing an external D/A (Digital to Analog) Converter using C |
|
|
315 | (2) |
|
|
317 | (4) |
|
11 PIC18FCCP And Serial I/O |
|
|
321 | (42) |
|
11.1 PIC18F CCP (Capture/Compare/PWM (Pulse Width Modulation) Module |
|
|
321 | (11) |
|
|
322 | (1) |
|
11.1.2 CCP modules and associated timers |
|
|
322 | (1) |
|
11.1.3 PIC 18F4321 Capture mode |
|
|
322 | (4) |
|
11.1.4 PIC18F4321 Compare mode |
|
|
326 | (3) |
|
11.1.5 PIC18F4321 PWM (Pulse Width Modulation) mode |
|
|
329 | (3) |
|
|
332 | (4) |
|
|
336 | (2) |
|
11.3.1 Synchronous Serial Data Transmission |
|
|
336 | (1) |
|
11.3.2 Asynchronous Serial Data Transmission |
|
|
337 | (1) |
|
11.3.3 Basics of SPI and I2C |
|
|
337 | (1) |
|
|
338 | (25) |
|
|
338 | (10) |
|
11.4.2 PIC 18F PC (Inter-Integrated Circuit) mode |
|
|
348 | (11) |
|
|
359 | (4) |
|
APPENDIX A ANSWERS TO SELECTED PROBLEMS |
|
|
363 | (8) |
|
|
371 | (12) |
|
APPENDIX C PIC18F INSTRUCTION SET (ALPHABETICAL ORDER) |
|
|
383 | (6) |
|
APPENDIX D PIC18F INSTRUCTION SET -- DETAILS |
|
|
389 | (44) |
|
APPENDIX E PIC18F4321 SPECIAL FUNCTION REGISTERS |
|
|
433 | (2) |
|
APPENDIX F TUTORIAL FOR ASSEMBLING AND DEBUGGING A PIC18F ASSEMBLY LANGUAGE PROGRAM USING THE MPLAB |
|
|
435 | (30) |
|
APPENDIX G TUTORIAL FOR COMPILING AND DEBUGGING A C-PROGRAM USING THE MPLAB |
|
|
465 | (28) |
|
APPENDIX H INTERFACING THE PIC18F4321 TO A PERSONAL COMPUTER OR A LAPTOP USING PICKIT™3 |
|
|
493 | (6) |
|
H.1 Initial Hardware Setup For The PIC18F4321 |
|
|
493 | (1) |
|
H.2 Connecting The Personal Computer (PC) Or The Laptop To The PIC 18F4321 VIA PICkit3 |
|
|
494 | (1) |
|
H.3 Programming The Pic 18F4321 From A Personal Computer Or A Laptop Using The PICkit3 |
|
|
495 | (4) |
Bibliography |
|
499 | (2) |
Index |
|
501 | |