Professional Documents
Culture Documents
6/27/05
2:26 PM
Page vii
Contents
Acknowledgments
Preface
1
Learning Objectives
Introduction to Microprocessors and Microcontrollers
The PIC18Fxx2 Microcontroller
Data Memory Organization and Data Transfer
xv
xvii
1
1
2
5
6
10
17
21
25
27
29
29
31
31
32
34
39
47
47
47
51
51
52
53
55
vii
378-5 Reese FM
6/27/05
viii
2:26 PM
Page viii
Contents
77
77
78
83
85
94
97
100
100
103
61
64
73
73
74
Learning Objectives
Subroutines
The Stack and Call/Return
Implementing Subroutines in Assembly Language
Arrays and Pointers in C
Arrays and Pointers in Assembly Language
Accessing Table Data from Program Memory
103
104
105
114
119
120
127
129
129
133
133
134
136
141
146
152
160
378-5 Reese FM
6/27/05
2:26 PM
Page ix
Contents
Asynchronous Serial IO
9.1
9.2
9.3
9.4
Learning Objectives
IO Channel Basics
Synchronous Serial IO
Asynchronous Serial IO
ix
162
169
170
175
175
176
183
188
192
197
199
204
204
207
207
208
210
216
220
223
225
228
231
237
242
249
249
253
253
254
257
259
378-5 Reese FM
6/27/05
2:26 PM
Page x
Contents
10
11
Synchronous Serial IO
11.1 Learning Objectives
11.2 The PIC18 and Synchronous Serial IO
11.3 USART Synchronous Mode
11.4 The Serial Peripheral Interface (SPI)
11.5 SPI Examples: A Digital Potentiometer and a Serial EEPROM
11.6 The I2C Bus
11.7 The I2C on the PIC18Fxx2
11.8 The 24LC515 Serial EEPROM
11.9 Double Buffering for Interrupt-Driven Writes
Summary
Review Problems
263
270
273
277
278
281
281
282
284
287
291
296
299
304
307
309
315
319
321
322
327
327
328
329
331
334
345
348
356
364
366
367
378-5 Reese FM
6/27/05
2:26 PM
Page xi
Contents
12
Data Conversion
12.1 Learning Objectives
12.2 Data Conversion Basics
12.3 Analog-to-Digital Conversion
12.4 PIC18Fxx2 Analog-to-Digital Converter
12.5 Digital-to-Analog Conversion
12.6 Digital-to-Analog Converter Example: The MAXIM 518
Summary
Review Problems
13
Timers
13.1 Learning Objectives
13.2 The Timer0 Subsystem
13.3 The Timer1 and Timer3 Subsystems
13.4 Pulse Width Measurement Using Capture Mode
13.5 Timer1/Timer3 Compare Mode
13.6 Using Capture Mode for Infrared Decoding
13.7 Timer2 and Pulse Width Modulation
13.8 Using Capture Mode for Frequency Measurement
Summary
Review Problems
14
xi
371
371
372
373
382
391
400
406
407
411
411
412
419
422
428
433
442
447
451
452
455
456
456
459
466
469
475
483
494
504
505
378-5 Reese FM
6/27/05
xii
15
2:26 PM
Page xii
Contents
507
507
508
513
516
528
523
527
531
533
534
537
549
553
557
D.1
D.2
D.3
D.4
SSCANF)
Lab Setup
Experiment 1: A Stored Program Machine (Chapters 1, 2)
Experiment 2: PIC18xx2 Introduction (Chapter 3)
Experiment 3: Unsigned 8-Bit Operations (Chapter 4)
Experiment 4: Extended Precision and Signed Operations (Chapter 5)
Experiment 5: Pointers and Subroutines (Chapter 6)
Experiment 6: Hardware Startup (Chapter 8)
Experiment 7: LED/Switch IO and Introduction to Asynchronous
Serial IO (Chapters 8, 9)
E.9 Experiment 8: Interrupts (Chapter 10)
557
559
560
560
563
563
566
567
569
572
573
575
578
580
378-5 Reese FM
6/27/05
2:26 PM
Page xiii
Contents
E.10 Experiment 9: More Interrupts, the I2C Bus, and a Serial EEPROM
(Chapter 11)
E.11 Experiment 10: Introduction to Data Conversion (Chapter 12)
E.12 Experiment 11: Timer Introduction and Waveform Generation
(Chapters 10, 13)
E.13 Experiment 12: Time Measurement and IR Waveform Decoding
(Chapter 13)
E.14 Experiment 13: Audio Record/Playback (Chapter 14)
E.15 Hardware Debugging Checklist
E.16 Instrumentation and Prototyping Hints
xiii
583
585
587
593
594
595
598
601
601
605
608
610
613
613
618
Appendix H References
621
625
I.1 Chapter 1
I.2 Chapter 2
I.3 Chapter 3
I.4 Chapter 4
I.5 Chapter 5
I.6 Chapter 6
I.7 Chapter 7
I.8 Chapter 8
I.9 Chapter 9
I.10 Chapter 10
I.11 Chapter 11
I.12 Chapter 12
625
627
629
630
631
633
638
639
643
644
646
647
378-5 Reese FM
6/27/05
xiv
2:26 PM
Page xiv
Contents
I.13 Chapter 13
Index
649
655
655
657