(Computer communications and networks) sid katzen BSc, MSc, DPhil, MIEE, MIEEE, CEng (auth ) the quintessential PIC® microcontroller springer verlag london (2005)

574 34 0
(Computer communications and networks) sid katzen BSc, MSc, DPhil, MIEE, MIEEE, CEng (auth ) the quintessential PIC® microcontroller springer verlag london (2005)

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

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Computer Communications and Networks The Computer Communications and Networks series is a range of textbooks, monographs and handbooks It sets out to provide students, researchers and non-specialists alike with a sure grounding in current knowledge, together with comprehensible access to the latest developments in computer communications and networking Emphasis is placed on clear and explanatory styles that support a tutorial approach, so that even the most complex of topics is presented in a lucid and intelligible manner Also in this series: An Information Security Handbook John M.D Hunter 1-85233-180-1 Multimedia Internet Broadcasting: Quality, Technology and Interface Andy Sloane and Dave Lawrence (Eds.) 1-85233-283-2 Information Assurance: Surviving in the Information Environment Andrew Blyth and Gerald L Kovacich 1-85233-326-X UMTS: Origins, Architecture and the Standard Pierre Lescuyer (Translation Editor: Frank Bott) 1-85233-676-5 Designing Software for the Mobile Context: A Practitioner’s Guide Roman Longoria 1-85233-785-0 OSS for Telecom Networks: An Introduction to Network Management Kundan Misra 1-85233-808-3 From P2P to Web Services and Grids: Peers in a Client/Server World Ian Taylor 1-85233-869-5 Sid Katzen The Quintessential PIC Microcontroller Second Edition ® Sid Katzen, BSc, MSc, DPhil, MIEE, MIEEE, CEng School of Electrical and Mechanical Engineering, University of Ulster, Northern Ireland Series Editor Professor A.J Sammes, BSc, MPhil, PhD, FBCS, CEng CISM Group, Cranfield University, RMCS, Shrivenham, Swindon SN6 8LA, UK British Library Cataloguing in Publication Data A catalogue record for this book is available from the British Library Library of Congress Cataloging-in-Publication Data Katzen, Sid The quintessential PIC® microcontroller/Sid Katzen.—2nd ed p cm — (Computer communications and networks) Includes bibliographical references and index ISBN 1-85233-942-X (alk paper) Programmable controllers I Title II Computer communications and networks TJ223.P76K38 2005 629.8′9—dc22 2005042504 Apart from any fair dealing for the purposes of research or private study, or criticism or review, as permitted under the Copyright, Designs and Patents Act 1988, this publication may only be reproduced, stored or transmitted, in any form or by any means, with the prior permission in writing of the publishers, or in the case of reprographic reproduction in accordance with the terms of licences issued by the Copyright Licensing Agency Enquiries concerning reproduction outside those terms should be sent to the publishers The following are registered trademarks of Microchip Technology Incorporated in the United States of America and other countries: dsPIC, MPLAB, PIC, and PICSTART The following are trademarks of Microchip Technology Incorporated in the United States of America and other countries: ICSP, In-Circuit Serial Programming, and MPASM Computer Communications and Networks ISSN 1617-7975 ISBN-10: 1-85233-942-X ISBN-13: 978-1-85233-942-5 First Edition ISBN: 1-85233-309-X Springer Science+Business Media springeronline.com © Springer-Verlag London Limited 2005 First Edition published 2001 The use of registered names, trademarks, etc., in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant laws and regulations and therefore free for general use The publisher makes no representation, express or implied, with regard to the accuracy of the information contained in this book and cannot accept any legal responsibility or liability for any errors or omissions that may be made Typesetting: Output-ready electronic files provided by the author Printed and bound in the United States of America (MVY) Printed on acid-free paper In memory of Eva Jones Contents Preface to the Second Edition IX Preface to the First Edition XI Part I The Fundamentals Digital Representation Logic Circuitry 17 Stored Program Processing 43 Part II The Software The PIC16F84 Microcontroller 71 The Instruction Set 95 Subroutines and Modules 147 Interrupt Handling 185 Assembly Language Code Building Tools 213 High-Level Language 247 Part III The Outside World 10 The Real World 271 11 One Byte at a Time 293 12 One Bit at a Time 331 VIII Contents 13 Time Is of the Essence 401 14 Take the Rough with the Smooth 435 15 To Have and to Hold 483 16 Enhancing the Family 509 17 A Case Study 529 Appendices A Acronyms and Abbreviations 549 B Special-Purpose Register Structure for the PIC16F87XA 555 C C Instruction Set 557 Index 559 Preface to the Second Edition A second edition of this book has given me the opportunity to respond to suggestions from both students and correspondents from around the world, from disparate regions ranging from Scotland to Hawaii Since the time of the first edition written in the late 1990s, the Microchip PIC range has become the largest volume selling 8-bit MCU The mid-range family used in the original edition has continued to expand vigorously, with some of the exemplars used becoming essentially obsolete In addition, the enhanced-range 16-bit instruction line has been enlarged from virtually nothing to form a significant proportion of the family At the same time, new introductions to the original low- (or base-) end architecture continue apace Because of the close relationship between the low-, mid-, high- and enhanced-range lines, the focus of the new edition has stayed with the mid-range line up Virtually all diagrams have been modified, many extensively, and numerous additional new figures have been added Throughout the text, special attention has been paid to clarify the basic concepts In Part I, Chapter has been extensively rewritten with this in mind and to better integrate with Chapters and in Part II, both of which bear only a superficial relation to the original text Chapter 7, covering interrupt handling, has also been largely rewritten to elucidate a difficult topic Part III not only has been revised to use current exemplars, but has been extended to cover additional peripherals such as the Analog Comparator and Voltage Reference modules A new chapter covers the enhancedrange PIC18FXXX range With the exception of the first two and last chapters, all chapters have both fully worked examples and self-assessment questions As an extension to this, an associated Web site at http://www.engj.ulst.ac.uk/sidk/quintessential has the following facilities: • • • • • Solutions to self-assessment questions Further self-assessment questions Additional material Source code for all examples and questions in the text Pointers to development software and data sheets for devices used in the book X Preface to the Second Edition • Errata • Feedback from readers The manuscript was typeset by the author on a variety of Microsoft® Windows™ PCs using a Y&Y implementation of LATEX 2ε and the Lucida Bright font family Line drawings were created or modified with Autocad R13 and incorporated as encapsulated PostScript files Photographs were taken by the author using several Olympus digital cameras—which are absolutely full of microcontrollers! Hopefully, any gremlins have been exorcised, but if you find any or have any other suggestions, I will be happy to acknowledge such communications via the Web site Sid Katzen University of Ulster at Jordanstown July 2005 Preface to the First Edition Microprocessors and their microcontroller derivatives are a widespread, if rather invisible, part of the infrastructure of our twenty-first-century electronic and communications society In 1998, it was estimated1 that hidden in every home there were about 100 microcontrollers and microprocessors: in the singing birthday card, washing machine, microwave oven, television controller, telephone, personal computer and so on About 20 more lurked in the average family car, for example, monitoring in-tire radio pressure sensors and displaying critical data through a control area network (CAN) Around billion such devices are sold each year to implement the intelligence of these “smart” electronic devices, ranging from smart eggtimers through to aircraft management systems The evolution of the microprocessor from the first Intel device introduced in 1971 has revolutionised the structure of society, effectively creating the second Industrial Revolution at the beginning of the twenty-first century Although the microprocessor is better known for its role in powering the ubiquitous PC, where raw computing power is the goal, sales of microprocessors such as the Intel Pentium represent only around 2% of the total volume The vast majority of sales are of low-cost microcontrollers embedded into a dedicated-function digital electronic device, such as the smart card Here the emphasis is on the integration of the core processor with memory and input/output resources in the one chip This integrated computing system is known as a microcontroller In seeking to write a book in this area, the overall objective was to get the reader up-to-speed in designing small embedded microcontrollerbased systems, rather than using microcontrollers as a vehicle to illustrate computer architecture in the traditional sense This will hopefully give the reader confidence that, even at such an introductory level, he/she can design, construct, and program a complete working embedded system Given the practical nature of this material, real-world hardware and software products are used throughout to illustrate the material The microcontroller market is dominated by devices that operate on 8-bit data (although 4- and 16-bit examples are available) like early microprocessors and unlike the 64-bit Intel Pentium and Motorola Power PC New Scientist, vol 59, no 2141, July 1998, p 139 ... Services and Grids: Peers in a Client/Server World Ian Taylor 1-85233-869-5 Sid Katzen The Quintessential PIC Microcontroller Second Edition ® Sid Katzen, BSc, MSc, DPhil, MIEE, MIEEE, CEng School... from the British Library Library of Congress Cataloging-in-Publication Data Katzen, Sid The quintessential PIC® microcontroller /Sid Katzen. —2nd ed p cm — (Computer communications and networks) Includes... get_timer1 (), 429 get_timer2 (), 419 getch (), 382 i2c_read (), 370 i2c_start (), 370 i2c_stop (), 370 i2c_write (), 370 if else, 260 int, 252 long int, 248, 252, 469 main (), 250 printf (), 382 read_adc (),

Ngày đăng: 16/12/2019, 17:01

Tài liệu cùng người dùng

Tài liệu liên quan