1. Trang chủ
  2. » Giáo Dục - Đào Tạo

10 2 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

PROGRAMMING AND CUSTOMIZING THE COPIES S°LD' ® rd EDITIO N Microcontroller | FOCUS: major PIC MCU families and their roles in the applications that use them I LANGUAGES: Assembly, BASIC, and C— the most popular for PIC programming • INSTRUCTIONS: Set up your own PIC microcontroller development lab • APPLICATIONS: Work on 100 complete experiments, and customize to your own specifications Includes valuable coupons fo r creating yo u r o w n PIC® m icro co n tro lle r de velopm e nt lab TAB ELECTRONICS tg/g Myke Predko PROGRAMMING AND CUSTOMIZING THE PIC® MICROCONTROLLER About the Author A resident of Toronto, Canada, Myke Predko is the best-selling author of 13 McGraw-Hill electronics and engineering titles, including Digital Electronics Demystified and 123 Robotics Experiments for the Evil Genius He holds a B.S.E.E from the University of Waterloo, and is the Electrical Engineering/Firmware Development Manager for Logitech’s Harmony Remote Control Business Unit PROGRAMMING AND CUSTOMIZING THE PIC® MICROCONTROLLER MYKE PREDKO Third Edition New York Chicago San Francisco Lisbon London Madrid Mexico City Milan New Delhi San Juan Seoul Singapore Sydney Toronto Copyright © 2008,2002, 1997 by The McGraw-Hill Companies, Inc All rights reserved Printed in the United States of America Except as permitted under the United States Copyright Act of 1976, no part o f this publication may be reproduced or distributed in any form or by any means, or stored in a data base or retrieval system, without the prior written permission of the publisher QVS/QVS 19 18 17 16 15 ISBN 978-0-07-147287-6 MHID 0-07-147287-8 Sponsoring Editor: Judy Bass Production Supervisor: Richard C Ruzycka Editing Supervisor: Stephen M Smith Project Manager: Preeti Longia Sinha Copy Editors: James K Madru and Lunaea Weatherstone Proofreader: Karen Vaucrosson Indexer: WordCo Indexing Services Art Director, Cover: Jeff Weeks Composition: International Typesetting and Composition Printed and bound by Quad/Graphics McGraw-Hill books are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs For more information, please write to the Director of Special Sales, M cGraw-Hill Professional, Two Penn Plaza, New York, NY 10121-2298 Or contact your local bookstore This book is printed on acid-free paper Information contained in this work has been obtained by The McGraw-Hill Companies, Inc (“McGraw-Hill”) from sources believed to be reliable However, neither McGraw-Hill nor its authors guarantee the accuracy or completeness of any informa­ tion published herein, and neither McGraw-Hill nor its authors shall be responsible for any errors, omissions, or damages arising out of use of this information This work is published with the understanding that McGraw-Hill and its authors are supplying information but are not attempting to render engineering or other professional services If such services are required, the assistance of an appropriate professional should be sought CONTENTS xl Introduction Acknowledgments Chapter xx/ Chapter 28 39 The Microchip PIC Microcontroller Accessing the Microchip Web Site 43 PIC Microcontroller Feature Summary 48 Features Unique to the PIC Microcontroller PIC Microcontroller Families 59 Chapter Programming PIC Microcontroller* 210 213 155 166 Emulators and Debugger* MPLAB ICE-2000 MPLAB REAL ICE 63 83 103 Hex File Format 156 Code Protection 158 Parallel Programming 159 PIC ICSP Programmer Interface Microchip Programmers 178 My Programmers 181 Third-Party Programmers 204 Chapter 43 54 Software Development Toole Tools Overview 65 High Level Languages Microchip MPLAB IDE Chapter Embedded Microcontroller* Microcontroller Types ) Internal Hardware Applications Processor Architectures Instructions and Software 12 Peripheral Functions 17 Memory Types 21 Microcontroller Communication Device Packaging 35 Application Development Tools 207 MPLAB ICD Debugger 219 The Emu-ll Other Emulators 241 Chapter 214 The Microchip PIC MCU Processor Architecture 243 The CPU 244 Hardware and File Registers 248 The PIC Microcontroller’s ALU 254 Data Movement 260 The Program Counter and Stack 264 Reset 268 Interrupts 271 Architecture Differences 273 Chapter Chapter 293 Using the PIC MCU Instruction Set Setting Up the MPLAB IDE Simulator with a Test Template PIC MCU Instruction Types 297 303 The Mid-Range Instruction Set Low-End PIC Microcontroller Instruction Set 348 PIC18 Instruction Set 356 Assembly-Language Software Techniques 294 373 Sample Template 374 Labels, Addresses, and Flags 376 Subroutines with Parameter Passing 381 Subtraction, Comparing and Negation 385 Bit AND and OR 389 16-Bit Operations 390 MulDiv, Constant Multiplication and Division 392 Delays 400 Patch Space 405 Structures, Pointers, and Arrays 407 Sorting Data 414 Interrupts 419 Reentrant Subroutines 423 Simulating Logic 423 Event-Driven Programming 426 State Machine Programming 429 Porting Code Between PIC Microcontroller Device Architectures 430 Optimizing PIC Microcontroller Applications 438 A Baker's Dozen Rules to Follow That Will Help to Avoid Application Software Problems 443 Chapter 445 Basic Operating Features Power Input and Decoupling 446 Configuration Fuses 451 OPTION Register 470 TMRO 478 Interrupt Operation 483 The Right PIC Microcontroller to Learn On 485 C O W T K H ia Chapter 10 489 Macro Development PIC Microcontroller Assembly-Language Macros 489 The Difference Between Defines and Macros 492 The Assembler Calculator 494 Multiline C Macros 499 Conditional Assembly/Compilation 500 Using Defines and Conditional Assembly for Application Debug Debugging Macros 509 Structured Programming Macros 513 Chapter 11 Chapter 12 507 519 Building and Linking Creating Linked Applications »11 519 527 Bootloaders Bootloader Requirements 528 Mid-Range Bootloaders 530 PIC18 Bootloaders 535 Chapter 13 Chapter 14 537 Real-Time Operating Systems Low-End and Mid-Range RTOSs PIC18 RTOS Design 542 541 565 Debugging Your Applications Document the Expected State 566 Characterize the Problem 567 Hypothesize and Test Your Hypothesis 569 Propose Corrective Actions 571 Test Fixes 572 Release Your Solution 576 Debug: An Application to Test Your Debug Skills 577 Chapter 15 PIC Microcontroller Application Design ind Hardware Interfacing Requirements Definition 590 PIC Microcontroller Resource Allocation Effective User Interfacing 597 Project Management 599 Power Management 603 Reset 608 Interfacing to External Devices 611 Chapter 16 589 595 PIC MCU Optional Hardware Features Mid-Range Built-in EEPROM/Flash Access 618 TMR1 624 TMR2 626 Compare/Capture/PWM (CCP) Module 628 Serial I/O 633 Analog I/O 649 Parallel Slave Port (PSP) 657 In-Circuit Serial Programming (ICSP) 659 917 »Ill CONTENTS Chapter 17 PIC MCU input and Output Device Interfacing LEDs 661 Switch Bounce 665 Matrix Keypads 668 LCDs 672 Analog I/O 682 Audio Output 690 Relays and Solenoids 692 Asynchronous (NRZ) Serial Interfaces Synchronous Serial Interfaces 704 Chapter 18 661 693 711 Motor Control Dc Motors 711 Stepper Motors 724 R/C Servo Control 733 Chapter 19 Chapter 20 739 Practical PC Interfacing PC Software Application Development Tools Serial Port 742 Parallel Port 749 740 PIC Microcontroller Application Basics 755 Jumping Around 755 771 Some Basic Functions Analog Input/Output 798 I/O with Interrupts 810 Serial I/O 832 Chapter 21 Projects 053 Low-End Devices 853 Mid-Range Devices 878 PIC18 Devices 953 Appendix A Resources Microchip 965 Books to Help You Learn Moreabout the PIC Microcontroller Useful Books 967 Recommended PIC Microcontroller Websites 970 Periodicals 971 Other Websites of Interest 972 Part Suppliers 973 Appendix B PIC Microcontroller Summary Feature to Part Number Table 977 Instruction Sets 977 I/O Register Addresses 1016 Device Pinouts 1030 965 966 977 CONTENTS Appendix C h 1061 Useful Tables and Data Electrical Engineering Formulas 1063 Mathematical Formulas 1065 Mathematical Conversions 1066 ASCII 1067 Appendix D Miscellaneous Electronic Reference Information Basic Electronic Components and Their Symbols Test Equipment 1080 Appendix E Basic Programming Language PICBASIC Appendix F 1073 1073 1089 1091 C Programming Language 1123 Common Library Functions 1130 PICC Library Functions 1133 Microchip C18 Library Functions 1138 Appendix Q Reuse, Return, and Recycle 1149 Useful Snippets 1150 Mykemacs.inc 1160 Sixteen-Bit Numbers 1200 Glossary 1213 Index 1229 .. .PROGRAMMING AND CUSTOMIZING THE PIC® MICROCONTROLLER About the Author A resident of Toronto, Canada, Myke Predko is the best-selling author of 13 McGraw-Hill electronics and engineering... 219 The Emu-ll Other Emulators 241 Chapter 214 The Microchip PIC MCU Processor Architecture 243 The CPU 244 Hardware and File Registers 248 The PIC Microcontroller? ??s ALU 254 Data Movement 260 The. .. xx/ Chapter 28 39 The Microchip PIC Microcontroller Accessing the Microchip Web Site 43 PIC Microcontroller Feature Summary 48 Features Unique to the PIC Microcontroller PIC Microcontroller Families

Ngày đăng: 22/10/2022, 13:40

TÀI LIỆU CÙNG NGƯỜI DÙNG

  • Đang cập nhật ...