8051 Microcontroller and Embedded Systems 129202657X, 9781292026572

Preface Introduction The Classical Period: Nineteenth Century Sociology Auguste Comte (1798-1857) on Women in Positivist

1,570 360 46MB

English Pages 640 [641] Year 2013

Report DMCA / Copyright

DOWNLOAD FILE

Polecaj historie

8051 Microcontroller and Embedded Systems
 129202657X, 9781292026572

Table of contents :
Cover......Page 1
Title......Page 2
Contents......Page 6
CHAPTER 0: INTRODUCTION TO COMPUTING......Page 16
Section 0.1 : Numbering and coding systems......Page 17
Section 0.2: Digital primer......Page 24
Section 0.3: Inside the computer......Page 28
CHAPTER 1: THE 8051 MICROCONTROLLERS......Page 38
Section 1. I : Microcontrollers and embedded processors......Page 39
Section 1.2: Overview of the 805 1 family......Page 43
CHAPTER 2: 8051 ASSEMBLY LANGUAGE PROGRAMMING......Page 52
Section 2.1 : Inside the 8051......Page 53
Section 2.2: Introduction to 8051 Assembly programming......Page 56
Section 2.3: Assembling and running an 8051 program......Page 59
Section 2.4: The program counter and ROM space in the 8051......Page 61
Section 2.5: 8051 data types and directives......Page 64
Section 2.6: 8051 flag bits and the PSW register......Page 67
Section 2.7: 8051 register banks and stack......Page 70
CHAPTER 3: JUMP, LOOP, AND CALL INSTRUCTIONS......Page 84
Section 3.1 : Loop and jump instructions......Page 85
Section 3.2: Call instructions......Page 90
Section 3.3 : Time delay for various 8051 chips......Page 95
CHAPTER 4: I/O PORT PROGRAMMING......Page 108
Section 4.1 : 8051 I/O programming......Page 109
Section 4.2: I/O bit manipulation programming......Page 115
CHAPTER 5: 8051 ADDRESSING MODES......Page 124
Section 5.1 : Immediate and register addressing modes......Page 125
Section 5.2: Accessing memory using various addressing modes......Page 127
Section 5.3: Bit addresses for I/O and RAM......Page 137
Section 5.4: Extra 128-byte on-chip RAM in 8052......Page 146
CHAPTER 6: ARITHMETIC & LOGlC INSTRUCTIONSAND PROGRAMS......Page 154
Section 6.1 : Arithmetic instructions......Page 155
Section 6.2: Signed number concepts and arithmetic operations......Page 165
Section 6.3: Logic and compare instructions......Page 170
Section 6.4: Rotate instruction and data serialization......Page 176
Section 6.5: BCD, ASCII, and other application programs......Page 182
CHAPTER 7: 8051 PROGRAMMING INC......Page 196
Section 7.1 : Data types and time delay in 8051 C......Page 197
Section 7.2: 110 programming in 8051 C......Page 203
Section 7.3: Logic operations in 8051 C......Page 209
Section 7.4: Data conversion programs in 8051 C......Page 214
Section 7.5: Accessing code ROM space in 8051 C......Page 219
Section 7.6: Data serialization using 8051 C......Page 224
CHAPTER 8: 8051 HARDWARE CONNECTION ANDINTEL HEX FILE......Page 232
Section 8.1: Pin description of the 8051......Page 233
Section 8.2: Design and test of DS89C4xO trainer......Page 239
Section 8.3: Explaining the Intel hex file......Page 247
CHAPTER 9: 8051 TIMER PROGRAMMINGIN ASSEMBLY AND C......Page 254
Section 9.1 : Programming 8051 timers......Page 255
Section 9.2: Counter programming......Page 270
Section 9.3: Programming timers 0 and 1 in 8051 C......Page 275
CHAPTER 10: 8051 SERIAL PORT PROGRAMMING IN ASSEMBLY AND C......Page 292
Section 10.1 : Basics of serial communication......Page 293
Section 10.2: 8051 connection to RS232......Page 300
Section 10.3: 8051 serial port programming in Assembly......Page 302
Section 10.4: Programming the second serial port......Page 315
Section 10.5: Serial port programming in C......Page 321
CHAPTER 11: INTERRUPTS PROGRAMMINGIN ASSEMBLY AND C......Page 332
Section 11.1 : 8051 interrupts......Page 333
Section 11.2: Programming timer interrupts......Page 337
Section 11.3 : Programming external hardware interrupts......Page 341
Section 11.4: Programming tlie serial communication interrupt......Page 348
Section 11.5: Interrupt priority in the 8051/52......Page 352
Section 11.6: Interrupt programming in C......Page 355
CHAPTER 12: LCD AND KEYBOARD INTERFACING......Page 366
Section 12.1 : LCD interfacing......Page 367
Section 12.2: Keyboard interfacing......Page 378
CHAPTER 13: ADC, DAC, AND SENSOR INTERFACING......Page 388
Section 13.1 : Parallel and serial ADC......Page 389
Section 13.2: DAC interfacing......Page 413
Section 13.3: Sensor interfacing and signal conditioning......Page 418
CHAPTER 14: 8051 INTERFACING TO EXTERNAL MEMORY......Page 426
Section 14.1 : Semiconductor memory......Page 427
Section 14.2: Memory address decoding......Page 437
Section 14.3: 8031/51 interfacing with external ROM......Page 440
Section 14.4: 8051 data memory space......Page 445
Section 14.5: Accessing external data memory in 8051 C......Page 455
CHAPTER 15: 8051 INTERFACING WITH THE 8255......Page 464
Section 15.1 : Programming the 8255......Page 465
Section 15.2: 8255 interfacing......Page 473
Section 15.3: 8051 C programming for the 8255......Page 477
CHAPTER 16: DS12887 RTC INTERFACINGAND PROGRAMMING......Page 482
Section 16.1 : DS 12887 RTC interfacing......Page 483
Section 16.2: DS12887 RTC programming in C......Page 491
Section 16.3: Alarm, SQW, and IRQ features of the DS12887 chip......Page 494
CHAPTER 17: MOTOR CONTROL: RELAY, PWM, DC,AND STEPPER MOTORS......Page 506
Section 17.1 : Relays and optoisolators......Page 507
Section 17.2: Stepper motor interfacing......Page 513
Section 17.3: DC motor interfacing and PWM......Page 522
APPENDIX A: 805 1 INSTRUCTIONS, TIMING, AND REGISTERS......Page 538
APPENDIX B: BASICS OF WIRE WRAPPING......Page 578
APPENDIX C: IC TECHNOLOGY AND SYSTEM DESIGN ISSUES......Page 582
APPENDIX D: FLOWCHARTS AND PSEUDOCODE......Page 602
APPENDIX E: 8051 PRIMER FOR X86 PROGRAMMERS......Page 607
APPENDIX F: ASCII CODES......Page 609
APPENDIX G: ASSEMBLERS, DEVELOPMENT RESOURCES,AND SUPPLIERS......Page 611
APPENDIX H: DATA SHEETS......Page 613
INDEX......Page 639

Citation preview

Pearson New International Edition

The8051 8051 Microcontroller & Embedded The Microcontroller & Embedded Systems Systems Mazidi 2e Mazidi 2e

ISBN 978-1-29202-657-2

The 8051 Microcontroller and The 8051 Microcontroller and Embedded Systems Embedded Systems Mazidi Mazidi McKinlay Mazidi Mazidi McKinlay Second Edition Second Edition

9 781292 026572

www.pearson.com/uk

9781292026572_CV_Final.indd 1

7/2/13 1:55 PM

The 8051 Microcontroller and Embedded Systems Mazidi Mazidi McKinlay Second Edition

Pearson Education Limited Edinburgh Gate Harlow Essex CM20 2JE England and Associated Companies throughout the world Visit us on the World Wide Web at: www.pearsoned.co.uk © Pearson Education Limited 2014 All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, electronic, mechanical, photocopying, recording or otherwise, without either the prior written permission of the publisher or a licence permitting restricted copying in the United Kingdom issued by the Copyright Licensing Agency Ltd, Saffron House, 6–10 Kirby Street, London EC1N 8TS. All trademarks used herein are the property of their respective owners. The use of any trademark in this text does not vest in the author or publisher any trademark ownership rights in such trademarks, nor does the use of such trademarks imply any affiliation with or endorsement of this book by such owners.

ISBN 10: 1-292-02657-X ISBN 13: 978-1-292-02657-2

British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library Printed in the United States of America