11
Principles and Applications Microcontrollers 2K × 8 +5 V +5 V 8 2.2K 7 Segment common anode LEDs 7×2 8 ADC 0804 SC RD Vin+ P0 P1.7 RST P2 Microcontroller AT89S52 P1(0-6) & P3(0-6) 8 bit dip switch X1 X2 P3.7 +5 V Op-Amp 27K +12 V 220 V 10K 47K 100K 2.2K D1 LM 35 22 pF 10K 22 pF XTAL 100E 10 uF +5 V Reset switch 1K Heater Ajit Pal

Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

  • Upload
    others

  • View
    87

  • Download
    11

Embed Size (px)

Citation preview

Page 1: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

Principles and ApplicationsMicrocontrollers

2K × 8

+5 V

+5 V

8

2.2K

7 Segmentcommon anodeLEDs

7×2

8ADC0804

SC

RDVin+

P0

P1.7

RST

P2

MicrocontrollerAT89S52

P1(0-6)&

P3(0-6)

8 bit dipswitch

X1

X2

P3.7

+5 V

Op-Amp27K

+12 V220 V

10K47K

100K2.2K

D1

LM35

22 pF

10K

22 pF

XTAL

100E

10 uF+5 V

Reset switch

1KHeater

Ajit Pal

Page 2: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

Microcontrollers

Page 3: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

MicrocontrollersPrinciples and Applications

AJIT PAL

ProfessorDepartment of Computer Science and Engineering

Indian Institute of Technology Kharagpur

New Delhi-1100012011

Page 4: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

MICROCONTROLLERS: Principles and ApplicationsAjit Pal

© 2011 by PHI Learning Private Limited, New Delhi. All rights reserved. No part of this book maybe reproduced in any form, by mimeograph or any other means, without permission in writing fromthe publisher.

ISBN-978-81-203-4392-4

The export rights of this book are vested solely with the publisher.

Published by Asoke K. Ghosh, PHI Learning Private Limited, M-97, Connaught Circus,New Delhi-110001 and Printed by Raj Press, New Delhi-110012.

Page 5: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

In the Loving Memory ofMy Parents

Page 6: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

vii

Preface xvAcknowledgements xvii

1. INTRODUCTION 1–17Learning Objectives 11.1 Historical Background 21.2 Microprocessors versus Microcontrollers 51.3 Microcontroller Features 7

1.3.1 On-chip Oscillator 71.3.2 Large Number of Special-purpose Registers 71.3.3 Harvard Architecture 81.3.4 On-chip Program Memory 91.3.5 On-chip Data Memory 91.3.6 On-chip I/O Ports 91.3.7 Watchdog-Timer Reset 101.3.8 Powerful Interrupt Structure 111.3.9 Fast Context Switching 111.3.10 Built-in ADC 121.3.11 Built-in PWM 12

1.4 Educational Need 121.4.1 Hardware Design 131.4.2 Software Design 131.4.3 Hardware-Software Integration 14

1.5 Survey of Microcontrollers 141.6 Applications of Microcontrollers 16

Summary 16Review Questions 17

Fill in the Blanks 17Short Questions 17

Contents

Page 7: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

viii ● Contents

2. ARCHITECTURE OF THE INTEL 8051 18–38Learning Objectives 182.1 On-chip Oscillator and CPU Timing 192.2 Memory Organization 212.3 Register Organization 222.4 Multifunction I/O Ports 242.5 ALU Capability of 8051 282.6 Reset Operation 31

2.6.1 Power-on Reset 312.7 Interrupt Structure 322.8 The 8051 Family 35

Summary 36Review Questions 37

Fill in the Blanks 37Short Questions 37

3. INSTRUCTION SET: VOCABULARY OF THE MACHINE 39–81Learning Objectives 393.1 Data and Its Representation 413.2 Instruction Formats 44

3.2.1 Instruction Formats of 8051 473.3 Addressing Modes 48

3.3.1 Addressing Modes of 8051 563.4 Organization of the Instruction Set 59

3.4.1 Data Transfer Group 593.4.2 Logic Group 633.4.3 Arithmetic Group 663.4.4 Control Transfer Group 71

Summary 78Review Questions 80

Fill in the Blanks 80Short Questions 80

4. ASSEMBLY LANGUAGE PROGRAMMING 82–114Learning Objectives 824.1 Software Design Steps 83

4.1.1 Problem Specification 834.1.2 Design 834.1.3 Coding 874.1.4 Testing and Debugging 884.1.5 Documentation and Maintenance 88

4.2 Why Assembly Language Programming? 884.3 Assembly Language Format 89

Page 8: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

Contents ● ix

4.4 Simple Sequence Programs 914.4.1 Multi-byte Addition 914.4.2 Code Conversion 924.4.3 Binary to BCD Code Conversion 92

4.5 Program Looping 934.5.1 Multi-byte Addition 954.5.2 Checksum Byte Calculation 954.5.3 Delay Generation 964.5.4 Searching 994.5.5 Sorting 103

4.6 Subroutine Linkage 1044.6.1 Parameter Passing Using Registers 1074.6.2 Parameter Passing Using Memory 1084.6.3 Parameter Passing Using Stack 109

4.7 Subroutine Call versus Interrupt 1104.7.1 Software Interrupts 111

Summary 111Review Questions 112

Fill in the Blanks 112Short Questions 113

5. INTERFACING EXTERNAL MEMORY 115–142Learning Objectives 1155.1 Program Memories 116

5.1.1 Mask-programmable ROM 1175.1.2 Programmable ROM 1175.1.3 Electrically Programmable ROM 1185.1.4 Electrically Erasable and Programmable ROM 1195.1.5 Flash Memory 1195.1.6 Non-volatile RAM 120

5.2 Data Memories 1205.2.1 Static RAM 1205.2.2 Dynamic RAM 121

5.3 Important Memory Characteristics 1215.3.1 Electrical Characteristics 1215.3.2 Memory Organization 1215.3.3 Timing Characteristics 126

5.4 Interfacing External Memory to 8051 1285.4.1 External Program Memory Address Space 1295.4.2 External Data Memory Address Space 1295.4.3 The System Bus 1295.4.4 Interfacing of Program Memories 1345.4.5 Interfacing of Data Memory 138

Summary 140Review Questions 141

Fill in the Blanks 141Short Questions 141

Page 9: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

x ● Contents

6. DATA TRANSFER TECHNIQUES AND I/O PORTS 143–163Learning Objectives 1436.1 Data Transfer Techniques 144

6.1.1 Synchronous Mode 1456.1.2 Asynchronous Mode 1466.1.3 Interrupt-driven Mode 146

6.2 I/O Port 1486.2.1 The 8255A Programmable Peripheral Interface (PPI) 1496.2.2 Interfacing of 8255 to the Microcontroller 1556.2.3 8051 I/O Port Progrmming 157

Summary 161Review Questions 162

Fill in the Blanks 162Short Questions 163

7. INTERFACING FOR HUMAN INTERACTION 164–200Learning Objectives 1647.1 Interfacing of DIP Switches 1657.2 Keyboard 165

7.2.1 Interface Circuit 1667.2.2 Interfacing Issues 1687.2.3 Row-scanning Technique 1707.2.4 Scanning by Hardware 175

7.3 Interfacing of Display Devices 1767.3.1 Single LEDs 1767.3.2 Bi-colour LEDs 1797.3.3 Seven-segment LEDs 1807.3.4 Interfacing Multiple Seven-segment LEDs 182

7.4 Liquid Crystal Displays 1867.4.1 Multi-digit Seven-segment LCD Driver 1877.4.2 Intelligent LCD Display Module 188

Summary 199Review Questions 199

Fill in the Blanks 199Short Questions 200

8. INTERFACING OF TRANSDUCERS, SENSORS AND ACTUATORS 201–248Learning Objectives 2018.1 Transducers 203

8.1.1 Temperature Transducers 2048.1.2 Pressure and Displacement Transducers 2068.1.3 Light Sensors 209

8.2 Signal Conditioning Circuits 2108.3 Optocouplers 2178.4 Relays 218

Page 10: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

Contents ● xi

8.5 Digital-to-Analog Converters 2208.5.1 DAC Parameters 2218.5.2 DAC Realizations 222

8.6 Analog-to-Digital Converters 2298.6.1 Single Ramp Comparison Type ADC 2298.6.2 Dual-slope Integrator Type ADC 2318.6.3 Direct Type ADC 2328.6.4 Tracking Type ADC 2338.6.5 The Successive Approximation ADC Counter 2338.6.6 Microcontroller-based ADCs 2358.6.7 ADC Chips 2388.6.8 Bus Compatible ADCs 2388.6.9 DAC/ADC Specifications 239

8.7 Sample and Hold Amplifier 2408.8 Analog Multiplexer 2428.9 Data Acquisition Systems 243Summary 246Review Questions 247

Fill in the Blanks 247Short Questions 247

9. TIMER/COUNTER OPERATIONS 249–267Learning Objectives 2499.1 Software-based Approach 250

9.1.1 Clock Generation 2519.1.2 Pulse Width Modulated Signal 251

9.2 Hardware-based Approach 2529.2.1 Monostable Operation 2549.2.2 Astable Operation 255

9.3 Combined Hardware–Software-based Approach 2569.3.1 Registers Involved in Timer/Counter Operations 2569.3.2 Timer/Counter Clock Source 2589.3.3 Timer Modes of Operation 2599.3.4 Counting External Events 2619.3.5 Interaction between the Timer/Counter and the Processor 262

Summary 265Review Questions 266

Fill in the Blanks 266Short Questions 266

10. SERIAL MODE OF DATA TRANSFER 268–299Learning Objectives 26810.1 Serial Transmission Fundamentals 269

10.1.1 Modes of Data Transfer 270

Page 11: Ajit Pal Microcontrollers - KopyKitab · 6.2.2 Interfacing of 8255 to the Microcontroller 155 6.2.3 8051 I/O Port Progrmming 157 Summary 161 Review Questions 162 Fill in the Blanks

Microcontrollers : Principles AndApplications

Publisher : PHI Learning ISBN : 9788120343924 Author : PAL, AJIT

Type the URL : http://www.kopykitab.com/product/7489

Get this eBook

30%OFF