ebook img

Introduction to Microcontrollers: Architecture, Programming, and Interfacing of the Motorola 68Hc12 PDF

417 Pages·1999·26.852 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Introduction to Microcontrollers: Architecture, Programming, and Interfacing of the Motorola 68Hc12

Introduction to Microcontrollers Architecture, Programming, and Interfacing of the Motorola 68HC12 Academic Press Series in Engineering Series Editor J. David Irwin Auburn University Designed to bring together interdependent topics in electrical engineering, mechanical engineering, computer engineering, and manufacturing, the Academic Press Series in Engineering provides state-of-the-art handbooks, textbooks, and professional reference books for researchers, students, and engineers. This series provides readers with a com- prehensive group of books essential for success in modem industry. A particular emphasis is given to the applications of cutting-edge research. Engineers, researchers, and students alike will find the Academic Press Series in Engineering to be an indispensable part of their design toolkit. Published books in the series: Industrial Controls and Manufacturing, 1999, E. Kamen DSP Integrated Circuits, 1999, L. Wanhammar Time Domain Electromagnetics, 1999, S. M. Rao Single- and Multi-Chip Microcontroller Interfacing for the Motorola 68HC12, 1999, G. J. Lipovski Control in Robotics and Automation, 1999, B. K. Ghosh, N. Xi, T. J. Tarn Soft Computing and Intelligent Systems, 1999, N. K. Sinha, M. M. Gupta Introduction to Microcontrollers Architecture, Programming, and Interfacing of the Motorola 68HC12 G. Jack Lipovski Department of Electrical and Computer Engineering University of Texas Austin, Texas ACADEMIC PRESS A Harcourt Science and Technology Company San Diego London Boston New York Sydney Tokyo Toronto Disclaimer: This eBook does not include the ancillary media that was packaged with the original printed version of the book. This book is printed on acid-free paper. © Copyright © 1999 by Academic Press All rights reserved. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopy, recording, or any information storage and retrieval system, without permission in writing from the publisher. Academic Press A Harcourt Science and Technology Company 525 B. St., Suite 1900, San Diego, California 92101-4495, USA http://www.apnet.com Academic Press 24-28 Oval Road, London NW1 7DX, UK http://www.hbuk.co.uk/ap/ Library of Congress Catalog Card Number: 99-65099 ISBN: 0-12-451831-1 Printed in the United States of America 99 00 01 02 03 DS 9 8 7 6 5 4 3 2 1 Dedicated to my father, Joseph Lipovski LIMITED WARRANTY AND DISCLAIMER OF LIABILITY ACADEMIC PRESS ("AP") AND ANYONE ELSE WHO HAS BEEN INVOLVED IN THE CREATION OR PRODUCTION OF THE ACCOMPANYING CODE ("THE PRODUCT") CAN- NOT AND DO NOT WARRANT THE PERFORMANCE OR RESULTS THAT MAY BE OBTAINED BY USING THE PRODUCT. THE PRODUCT IS SOLD "AS IS" WITHOUT WAR- RANTY OF ANY KIND (EXCEPT AS HEREAFTER DESCRIBED), EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, ANY WARRANTY OF PERFORMANCE OR ANY IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR ANY PARTIC- ULAR PURPOSE. AP WARRANTS ONLY THAT THE MAGNETIC DISK(S) ON WHICH THE CODE IS RECORDED IS FREE FROM DEFECTS IN MATERIAL AND FAULTY WORK- MANSHIP UNDER THE NORMAL USE AND SERVICE FOR A PERIOD OF NINETY (90) DAYS FROM THE DATE THE PRODUCT IS DELIVERED. THE PURCHASER'S SOLE AND EXCLUSIVE REMEDY IN THE EVENT OF A DEFECT IS EXPRESSLY LIMITED TO EITHER REPLACEMENT OF THE DISK(S) OR REFUND OF THE PURCHASE PRICE, AT AP'S SOLE DISCRETION. IN NO EVENT, WHETHER AS A RESULT OF BREACH OF CONTRACT, WARRANTY OR TORT (INCLUDING NEGLIGENCE), WILL AP OR ANYONE WHO HAS BEEN INVOLVED IN THE CREATION OR PRODUCTION OF THE PRODUCT BE LIABLE TO PURCHASER FOR ANY DAMAGES, INCLUDING ANY LOST PROFITS, LOST SAVINGS OR OTHER INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILI- TY TO USE THE PRODUCT OR ANY MODIFICATIONS THEREOF, OR DUE TO THE CON- TENTS OF THE CODE, EVEN IF AP HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY. ANY REQUEST FOR REPLACEMENT OF A DEFECTIVE DISK MUST BE POSTAGE PRE- PAID AND MUST BE ACCOMPANIED BY THE ORIGINAL DEFECTIVE DISK, YOUR MAILING ADDRESS AND TELEPHONE NUMBER, AND PROOF OF DATE OF PURCHASE AND PURCHASE PRICE. SEND SUCH REQUESTS, STATING THE NATURE OF THE PROBLEM, TO ACADEMIC PRESS CUSTOMER SERVICE, 6277 SEA HARBOR DRIVE, ORLANDO, FL 32887, 1-800-321-5068. AP SHALL HAVE NO OBLIGATION TO REFUND THE PURCHASE PRICE OR TO REPLACE A DISK BASED ON CLAIMS OF DEFECTS IN THE NATURE OR OPERATION OF THE PRODUCT. SOME STATES DO NOT ALLOW LIMITATION ON HOW LONG AN IMPLIED WARRANTY LASTS, NOR EXCLUSIONS OR LIMITATIONS OF INCIDENTAL OR CONSEQUENTIAL DAMAGE, SO THE ABOVE LIMITATIONS AND EXCLUSIONS MAY NOT APPLY TO YOU. THIS WARRANTY GIVES YOU SPECIFIC LEGAL RIGHTS, AND YOU MAY ALSO HAVE OTHER RIGHTS WHICH VARY FROM JURISDICTION TO JURISDICTION. THE RE-EXPORT OF UNITED STATES ORIGIN SOFTWARE IS SUBJECT TO THE UNITED STATES LAWS UNDER THE EXPORT ADMINISTRATION ACT OF 1969 AS AMENDED. ANY FURTHER SALE OF THE PRODUCT SHALL BE IN COMPLIANCE WITH THE UNIT- ED STATES DEPARTMENT OF COMMERCE ADMINISTRATION REGULATIONS. COM- PLIANCE WITH SUCH REGULATIONS IS YOUR RESPONSIBILITY AND NOT THE RESPONSIBILITY OF AP. Contents Preface x i List of Figures xiv List of Tables xx Acknowledgments xxi About the Author xxii 1 Basic Computer Structure and the 6812 1 1.1 Basic Computer Structure 1 1.2 The Instruction 4 1.3 A Few Instructions and Some Simple Programs 8 1.4 MC68HC812A4 and MC68HC912B32 Organizations 16 1.5 Variable Word Width 19 1.6 Summary and Further Reading 21 Problems 23 2 The Instruction Set 27 2.1 Move Instructions 28 2.2 Arithmetic Instructions 34 2.3 Logic Instructions 38 2.4 Edit Instructions 41 2.5 Control instructions 42 2.6 Input-Output Instructions 49 2.7 Special Instructions 49 2.8 Remarks 51 Problems 53 3 Addressing 5 7 3.1 Op Code Byte Addressing Modes 58 .,2 Post-Byte Index Addressing Modes 60 3.3 Relative Addressing and Position Independence 67 3.4 Stack Index Addressing, Reentrancy, and Recursion 71 3.5 Examples 76 3.6 Architectural Notions of Addressing 78 vii i Table of Contents 3.7 Summary 81 Problems 82 4 Assembly Language Programming 87 4.1 Introductory Example and Assembler Printout 89 4.2 Assembler Directives 92 4.3 Mechanics of a Two-Pass Assembler 96 4.4 Character String Operations 99 4.5 A Simplified Two-Pass Assembler 103 4.6 Summary 107 Problems 109 5 Advanced Assemblers, Linkers, and Loaders 119 5.1 Cross Assemblers and Downloaders 119 5.2 Relocatable Assemblers and Loaders 123 5 3 Conditional Assemblers 125 5.4 Macro Assemblers 127 5.5 Documentation 130 5.6 Summary 132 Problems 133 6 Assembler Language Subroutines 137 6.1 Local Variables 139 6.2 Passing Parameters 149 6.3 Passing Arguments by Value, Reference, and Name 162 6.4 Calling and Returning Mechanisms 163 6.5 Summary 172 Problems 173 7 Arithmetic Operations 179 7.1 Multiplication and Division 180 7.2 Integer Conversion 183 7.3 From Formulas to Subroutine Calls 191 7.4 Long Integer Arithmetic 196 7.5 Floating-Point Arithmetic and Conversion 20.1 7.6 Fuzzy Logic 210 7.7 Summary 215 Problems 217 8 Programming in C and C++ 221 8.1 Compilers and Interpreters 221 8.2 Operators and Assignment Statements 223 8.3 Conditional and Loop Statements 226 Table of Contents ix 8.4 Constants and Variables 227 8.5 Procedures and Their Arguments 231 8.6 An Example 233 8.7 Object-Oriented Programming in C++ 236 8.8 Summary 245 Problems 246 9 Implementation of C Procedures 253 9.1 Global and Local Variables 254 9.2 Expressions and Assignment Statements 257 9.3 Conditional Statements 265 9.4 Loop Statements, Arrays, and Structs 274 9.5 Procedure Calls and Arguments 279 9.6 Examples from Character String Procedures 282 9.7 Summary 286 Problems 287 10 Elementary Data Structures 291 10.1 What a Data Structure Is 291 10.2 Indexable Data Structures 293 10.3 Sequential Data Structures 298 10.4 Linked List Structures 304 10.5 Summary 310 Problems 311 11 Input/Output 317 11.1 Input and Output Devices 317 11.2 Parallel Ports 320 11.3 Input and Output Software 322 11.4 Synchronization Hardware 325 11.5 Gadfly Synchronization 326 11.6 Interrupt Synchronization 329 11.7 Analog-to-Digital and Digital-to-Analog Conversion 334 11.8 UART Protocol 337 11.9 Summary and Further Reading 340 Problems 341 12 Other Microcontrollers 349 12.1 The 6811 349 12.2 The 6808 352 12.3 The 6805 356 12.4 The 68300 Series 358 12.5 The 500 Series 367

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.