12

Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

  • Upload
    others

  • View
    14

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari
Page 2: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

Microprocessor

andMicrocontroller

Second Edition

C. LathaSenior Lecturer (fmr)

&

B. MurugeshwariHead of the Department

Dept. of Electronics and Communication EngineeringK.Ramakrishnan College of Engineering

SamayapuramTrichy - 621 112

SCITECH PUBLICATIONS (INDIA) PVT. LTD.www.scitechpublications.com

Page 3: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

Contents

Chapter 1 Introduction to Microprocessor 1 - 101.1 Introduction to Microprocessors . . . . . . . . . . . . . . . . . . 1

1.1.1 Evolution of microprocessor . . . . . . . . . . . . . . . . 11.1.2 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 11.1.3 Timeline of microprocessor evolution . . . . . . . . . . . 21.1.4 Classification of microprocessors . . . . . . . . . . . . . 21.1.5 Functional block diagram of microprocessor . . . . . . . 31.1.6 Advantages of microprocessor . . . . . . . . . . . . . . . 4

1.2 Computer and its Organization . . . . . . . . . . . . . . . . . . . 41.3 Programming System . . . . . . . . . . . . . . . . . . . . . . . . 6

1.3.1 Programming languages . . . . . . . . . . . . . . . . . . 61.3.2 Format of an assembly language instruction . . . . . . . . 71.3.3 Assembly language program - development tools . . . . . 8

1.4 Buses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.4.1 Types of buses . . . . . . . . . . . . . . . . . . . . . . . 91.4.2 Example - memory read operation . . . . . . . . . . . . . 9

1.5 Tristate Bus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Chapter 2 The Intel 8086 Microprocessor 11 - 1072.1 Features of 8086 . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Architecture of 8086 . . . . . . . . . . . . . . . . . . . . . . . . 12

2.2.1 Bus Interface Unit [BIU] . . . . . . . . . . . . . . . . . . 122.2.2 Execution Unit (EU) . . . . . . . . . . . . . . . . . . . . 15

2.3 Interrupt Processing . . . . . . . . . . . . . . . . . . . . . . . . . 182.3.1 Response to an interrupt . . . . . . . . . . . . . . . . . . 192.3.2 Classification of interrupts . . . . . . . . . . . . . . . . . 192.3.3 Interrupt priority . . . . . . . . . . . . . . . . . . . . . . 202.3.4 Interrupt sequence for INTR . . . . . . . . . . . . . . . . 212.3.5 Interrupt Service Routines (ISR) . . . . . . . . . . . . . . 21

2.4 Introduction to Programming . . . . . . . . . . . . . . . . . . . . 232.5 Memory Address Computation . . . . . . . . . . . . . . . . . . . 232.6 Addressing Modes of 8086 . . . . . . . . . . . . . . . . . . . . . 23

2.6.1 Register addressing mode . . . . . . . . . . . . . . . . . 242.6.2 Immediate addressing mode . . . . . . . . . . . . . . . . 242.6.3 Memory addressing modes . . . . . . . . . . . . . . . . . 252.6.4 I/O addressing mode . . . . . . . . . . . . . . . . . . . . 29

Page 4: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

2.6.5 Relative addressing mode . . . . . . . . . . . . . . . . . 302.7 Instruction Set of 8086 . . . . . . . . . . . . . . . . . . . . . . . 30

2.7.1 Data transfer instructions . . . . . . . . . . . . . . . . . . 302.7.2 I/O instructions . . . . . . . . . . . . . . . . . . . . . . . 332.7.3 Flag manipulation instructions . . . . . . . . . . . . . . . 342.7.4 Arithmetic instructions . . . . . . . . . . . . . . . . . . . 352.7.5 Logical instructions . . . . . . . . . . . . . . . . . . . . . 462.7.6 Shift and rotate instructions . . . . . . . . . . . . . . . . 482.7.7 String instructions . . . . . . . . . . . . . . . . . . . . . 542.7.8 Machine or processor control instructions . . . . . . . . . 552.7.9 Control transfer instructions . . . . . . . . . . . . . . . . 562.7.10 Interrupt instructions . . . . . . . . . . . . . . . . . . . . 62

2.8 Assembler Directives . . . . . . . . . . . . . . . . . . . . . . . . 632.9 8086 Assembly Language Programming . . . . . . . . . . . . . . 682.10 Modular Programming . . . . . . . . . . . . . . . . . . . . . . . 76

2.10.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 762.10.2 Linking and relocation . . . . . . . . . . . . . . . . . . . 772.10.3 Segment combination . . . . . . . . . . . . . . . . . . . . 79

2.11 Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 822.12 Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

2.12.1 Call . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852.12.2 RET . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 852.12.3 Procedure definition . . . . . . . . . . . . . . . . . . . . 852.12.4 Procedure communication . . . . . . . . . . . . . . . . . 862.12.5 Recursive procedures . . . . . . . . . . . . . . . . . . . . 87

2.13 Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 892.13.1 Macro definition . . . . . . . . . . . . . . . . . . . . . . 902.13.2 Nested macros . . . . . . . . . . . . . . . . . . . . . . . 92

2.14 BIOS Interrupts or Function Calls . . . . . . . . . . . . . . . . . 922.14.1 INT 10H . . . . . . . . . . . . . . . . . . . . . . . . . . 932.14.2 INT 11H . . . . . . . . . . . . . . . . . . . . . . . . . . 952.14.3 INT 12H . . . . . . . . . . . . . . . . . . . . . . . . . . 952.14.4 INT 13H . . . . . . . . . . . . . . . . . . . . . . . . . . 952.14.5 INT 14H . . . . . . . . . . . . . . . . . . . . . . . . . . 962.14.6 INT 15H . . . . . . . . . . . . . . . . . . . . . . . . . . 972.14.7 INT 16H . . . . . . . . . . . . . . . . . . . . . . . . . . 972.14.8 INT 17H . . . . . . . . . . . . . . . . . . . . . . . . . . 98Short Question with Answers . . . . . . . . . . . . . . . . . . . 98

Page 5: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

Chapter 3 8086 System Bus Structure 109 - 2143.1 8086 - Pins and Signals . . . . . . . . . . . . . . . . . . . . . . . 1093.2 External Memory Addressing . . . . . . . . . . . . . . . . . . . . 115

3.2.1 Case (i): 8 bit data transfer . . . . . . . . . . . . . . . . . 1163.2.2 Case(ii):16 bit transfer:16 bit data is stored in two

memory locations . . . . . . . . . . . . . . . . . . . . . . 1173.2.3 Memory segmentation . . . . . . . . . . . . . . . . . . . 1183.2.4 Advantages of memory segmentation . . . . . . . . . . . 118

3.3 Memory Interfacing . . . . . . . . . . . . . . . . . . . . . . . . . 1183.3.1 Interfacing EPROM to 8086 . . . . . . . . . . . . . . . . 1183.3.2 Inter facing RAM to 8086 . . . . . . . . . . . . . . . . . 1203.3.3 Generation of control signals for the memory . . . . . . . 121

3.4 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . 1213.5 8086 In Minimum Mode Configuration . . . . . . . . . . . . . . 122

3.5.1 Minimum mode . . . . . . . . . . . . . . . . . . . . . . . 1223.5.2 Minimum mode bus cycle . . . . . . . . . . . . . . . . . 122

3.6 8086 in Maximum Mode Configuration . . . . . . . . . . . . . . 1253.6.1 Maximum mode . . . . . . . . . . . . . . . . . . . . . . 1263.6.2 Maximum mode bus cycle . . . . . . . . . . . . . . . . . 127

3.7 Multiprocessor Configuration . . . . . . . . . . . . . . . . . . . . 1293.7.1 Multiprocessor . . . . . . . . . . . . . . . . . . . . . . . 1293.7.2 Need for multiprocessor system . . . . . . . . . . . . . . 1293.7.3 Advantages . . . . . . . . . . . . . . . . . . . . . . . . . 130

3.8 Configurations of Multiprocessor System . . . . . . . . . . . . . 1313.8.1 Coprocessor configuration . . . . . . . . . . . . . . . . . 1313.8.2 Closely coupled configuration . . . . . . . . . . . . . . . 1333.8.3 Loosely coupled configuration . . . . . . . . . . . . . . . 134

3.9 Interconnection Topologies . . . . . . . . . . . . . . . . . . . . . 1393.9.1 Shared bus architecture . . . . . . . . . . . . . . . . . . . 1393.9.2 Multiport memory . . . . . . . . . . . . . . . . . . . . . 1403.9.3 Linked Input / Output . . . . . . . . . . . . . . . . . . . . 1403.9.4 Cross bar switching . . . . . . . . . . . . . . . . . . . . . 140

3.10 Physical Interconnections between Processors . . . . . . . . . . . 1413.10.1 Star configuration . . . . . . . . . . . . . . . . . . . . . . 1413.10.2 Ring or loop configuration . . . . . . . . . . . . . . . . . 1423.10.3 Completely connected configuration . . . . . . . . . . . . 1423.10.4 Regular topology . . . . . . . . . . . . . . . . . . . . . . 1423.10.5 Irregular topology . . . . . . . . . . . . . . . . . . . . . 143

3.11 Intel 8087 - Numeric Data Processor . . . . . . . . . . . . . . . . 143

Page 6: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

3.11.1 Features of 8087 . . . . . . . . . . . . . . . . . . . . . . 1433.11.2 Architecture of 8087 . . . . . . . . . . . . . . . . . . . . 1443.11.3 Pins of 8087 . . . . . . . . . . . . . . . . . . . . . . . . 1503.11.4 Data types . . . . . . . . . . . . . . . . . . . . . . . . . . 1523.11.5 Interconnection of 8087 with 8086 . . . . . . . . . . . . . 1533.11.6 Communication between 8086 and 8087 . . . . . . . . . . 154

3.12 I/O Processor Intel 8089 . . . . . . . . . . . . . . . . . . . . . . 1553.12.1 Features of IOP 8089 . . . . . . . . . . . . . . . . . . . . 1563.12.2 Architecture of Intel 8089 . . . . . . . . . . . . . . . . . 1573.12.3 Pin diagram of 8089 . . . . . . . . . . . . . . . . . . . . 1603.12.4 Operation of 8089 . . . . . . . . . . . . . . . . . . . . . 1623.12.5 Communication between CPU and IOP . . . . . . . . . . 165

3.13 Introduction to Advanced Microprocessors . . . . . . . . . . . . . 1683.14 Intel 80186 Microprocessor . . . . . . . . . . . . . . . . . . . . . 169

3.14.1 Features of 80186 microprocessor . . . . . . . . . . . . . 1693.14.2 Addressing modes . . . . . . . . . . . . . . . . . . . . . 1733.14.3 Data types supported by 80186 microprocessor . . . . . . 1733.14.4 Additional instructions . . . . . . . . . . . . . . . . . . . 174

3.15 Intel 80286 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1743.15.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 1743.15.2 Functional diagram of 80286 microprocessor . . . . . . . 1753.15.3 Other important concepts related to 80286 microprocessor 1763.15.4 Modes of operation . . . . . . . . . . . . . . . . . . . . . 1773.15.5 Addressing modes of 80286 microprocessor: . . . . . . . 1783.15.6 Memory management features . . . . . . . . . . . . . . . 179

3.16 Intel 80386 Microprocessor . . . . . . . . . . . . . . . . . . . . . 1793.16.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 1793.16.2 Architecture of 80386 . . . . . . . . . . . . . . . . . . . 1803.16.3 Addressing modes . . . . . . . . . . . . . . . . . . . . . 1833.16.4 Modes of operation of 80386 microprocessor . . . . . . . 1843.16.5 Change of mode . . . . . . . . . . . . . . . . . . . . . . 1883.16.6 Addressing modes . . . . . . . . . . . . . . . . . . . . . 188

3.17 Intel 80486 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1893.17.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 1893.17.2 Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 1893.17.3 Register structure . . . . . . . . . . . . . . . . . . . . . . 1913.17.4 Other concepts related to 80486 . . . . . . . . . . . . . . 194

3.18 Pentium Processor . . . . . . . . . . . . . . . . . . . . . . . . . 1953.18.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

Page 7: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

Short Question with Answers . . . . . . . . . . . . . . . . . . . 203

Chapter 4 Microprocessor Peripheral Interfacing 215 - 3414.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2154.2 Features of Programmable Peripheral Devices . . . . . . . . . . . 2164.3 Requirements for a Programmable Peripheral Device . . . . . . . 2164.4 Elements of a Programmable Peripheral Device . . . . . . . . . . 2164.5 Generation of I/O Ports . . . . . . . . . . . . . . . . . . . . . . . 2174.6 Programmable Peripheral Interface Intel 8255 . . . . . . . . . . . 219

4.6.1 Features of 8255 . . . . . . . . . . . . . . . . . . . . . . 2194.6.2 Block diagram of intel 8255 . . . . . . . . . . . . . . . . 2204.6.3 Modes of operation . . . . . . . . . . . . . . . . . . . . . 2224.6.4 Bit Set/Reset mode (BSR) . . . . . . . . . . . . . . . . . 2234.6.5 I/O mode . . . . . . . . . . . . . . . . . . . . . . . . . . 224

4.7 Keyboard and Display Interface . . . . . . . . . . . . . . . . . . 2324.7.1 Keyboard interface . . . . . . . . . . . . . . . . . . . . . 2324.7.2 Display interface . . . . . . . . . . . . . . . . . . . . . . 235

4.8 Programmable Keyboard / Display Controller Intel 8279 . . . . . 2374.8.1 Features of Intel 8279 . . . . . . . . . . . . . . . . . . . 2374.8.2 Block diagram of 8279 . . . . . . . . . . . . . . . . . . . 2384.8.3 Signals of 8279 . . . . . . . . . . . . . . . . . . . . . . . 2404.8.4 Modes of operation . . . . . . . . . . . . . . . . . . . . . 2424.8.5 Programming the 8279 . . . . . . . . . . . . . . . . . . . 2444.8.6 Sequence of steps . . . . . . . . . . . . . . . . . . . . . . 2484.8.7 Examples to identify a key press . . . . . . . . . . . . . . 248

4.9 Programmable Timer / Counter Intel 8253 (8254) . . . . . . . . . 2504.9.1 Features of 8254 . . . . . . . . . . . . . . . . . . . . . . 2504.9.2 Block diagram of 8254 . . . . . . . . . . . . . . . . . . . 2514.9.3 Modes of operation . . . . . . . . . . . . . . . . . . . . . 2544.9.4 Programming the 8254 . . . . . . . . . . . . . . . . . . . 257

4.10 Analog to Digital Converters (ADC) . . . . . . . . . . . . . . . . 2604.10.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . 2604.10.2 Successive approximation A/D converter . . . . . . . . . 2614.10.3 ADC 0808 / 0809 . . . . . . . . . . . . . . . . . . . . . . 2624.10.4 Interfacing ADC 0808/0809 . . . . . . . . . . . . . . . . 2634.10.5 Flow chart for ADC conversion software . . . . . . . . . 2644.10.6 Program . . . . . . . . . . . . . . . . . . . . . . . . . . . 265

4.11 Digital to Analog converter (DAC) . . . . . . . . . . . . . . . . . 2654.11.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . 2654.11.2 Basic conversion techniques . . . . . . . . . . . . . . . . 266

Page 8: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

4.11.3 DAC 1408 . . . . . . . . . . . . . . . . . . . . . . . . . 2694.11.4 Interfacing DAC 1408 with microprocessor . . . . . . . . 2714.11.5 Flow chart for DAC Conversion . . . . . . . . . . . . . . 272

4.12 Intel 8259 - Programmable Interrupt Controller . . . . . . . . . . 2744.12.1 Features of Intel 8259 . . . . . . . . . . . . . . . . . . . 2754.12.2 Block diagram of 8259 . . . . . . . . . . . . . . . . . . . 2754.12.3 Pin details of 8259 . . . . . . . . . . . . . . . . . . . . . 2784.12.4 Interrupt operation . . . . . . . . . . . . . . . . . . . . . 2784.12.5 Programming the 8259 . . . . . . . . . . . . . . . . . . . 2804.12.6 Priority modes . . . . . . . . . . . . . . . . . . . . . . . 2834.12.7 End of interrupt . . . . . . . . . . . . . . . . . . . . . . . 2844.12.8 Additional features . . . . . . . . . . . . . . . . . . . . . 284

4.13 DMA - Direct Memory Access . . . . . . . . . . . . . . . . . . . 2844.14 Intel 8237 DMA Controller . . . . . . . . . . . . . . . . . . . . . 285

4.14.1 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 2864.14.2 Architecture of 8237 . . . . . . . . . . . . . . . . . . . . 2864.14.3 Pin details of 8237 . . . . . . . . . . . . . . . . . . . . . 2924.14.4 Initializing the 8237 . . . . . . . . . . . . . . . . . . . . 2944.14.5 DMA execution . . . . . . . . . . . . . . . . . . . . . . . 2954.14.6 Modes of DMA . . . . . . . . . . . . . . . . . . . . . . . 2964.14.7 Interfacing 8237 with 8085 . . . . . . . . . . . . . . . . . 297

4.15 Serial Communication . . . . . . . . . . . . . . . . . . . . . . . 2994.16 Intel 8251 USART . . . . . . . . . . . . . . . . . . . . . . . . . 300

4.16.1 Features of 8251 . . . . . . . . . . . . . . . . . . . . . . 3014.16.2 Block diagram of 8251 . . . . . . . . . . . . . . . . . . . 3014.16.3 Pin details of 8251 . . . . . . . . . . . . . . . . . . . . . 3044.16.4 Control words . . . . . . . . . . . . . . . . . . . . . . . . 3064.16.5 Asynchronous transmission . . . . . . . . . . . . . . . . 3084.16.6 Asynchronous reception . . . . . . . . . . . . . . . . . . 3084.16.7 Synchronous transmission . . . . . . . . . . . . . . . . . 3094.16.8 Synchronous reception . . . . . . . . . . . . . . . . . . . 3104.16.9 Interfacing 8251 With 8086 . . . . . . . . . . . . . . . . 310

4.17 Memory Interfacing . . . . . . . . . . . . . . . . . . . . . . . . . 3114.17.1 Memory organization in 8086 . . . . . . . . . . . . . . . 3114.17.2 Formation of system Bus . . . . . . . . . . . . . . . . . . 3134.17.3 Interfacing RAM and EPROM . . . . . . . . . . . . . . . 314

4.18 I/O Interfacing . . . . . . . . . . . . . . . . . . . . . . . . . . . 3154.18.1 I/O mapped I/O . . . . . . . . . . . . . . . . . . . . . . . 3154.18.2 Memory mapped I/O . . . . . . . . . . . . . . . . . . . . 316

Page 9: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

4.18.3 Interfacing an 8 bit input device with 8086 . . . . . . . . 3164.18.4 Interfacing an 8 bit output device with 8086 . . . . . . . . 318

4.19 Applications of 8086 . . . . . . . . . . . . . . . . . . . . . . . . 3204.19.1 Traffic light control . . . . . . . . . . . . . . . . . . . . . 3214.19.2 Interfacing LCD display with 8086 . . . . . . . . . . . . 3244.19.3 Interfacing 64 key matrix keyboard with the 8086 . . . . . 3304.19.4 Interfacing 8 digit 7 segment display with the 8086 . . . . 331Short Question with Answers . . . . . . . . . . . . . . . . . . . 335

Chapter 5 8 - Bit Microcontroller - The 8051 -Architecture 343 - 399

5.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3435.2 Features of Microcontrollers . . . . . . . . . . . . . . . . . . . . 3435.3 Differences between Microprocessor and Microcontroller . . . . 3445.4 Applications of Microcontrollers . . . . . . . . . . . . . . . . . . 3445.5 Intel 8051 Microcontroller . . . . . . . . . . . . . . . . . . . . . 3445.6 Comparison Between 8051 and 8031 . . . . . . . . . . . . . . . . 3455.7 Features of 8051 Microcontroller . . . . . . . . . . . . . . . . . . 3455.8 8051 - Architecture . . . . . . . . . . . . . . . . . . . . . . . . . 3455.9 Pins and Signals of 8051 . . . . . . . . . . . . . . . . . . . . . . 3505.10 Memory Organization . . . . . . . . . . . . . . . . . . . . . . . . 3535.11 Special Function Registers (SFR) . . . . . . . . . . . . . . . . . . 3565.12 I/O Port Operation . . . . . . . . . . . . . . . . . . . . . . . . . 357

5.12.1 Structure of port 0 . . . . . . . . . . . . . . . . . . . . . 3585.12.2 Structure of port 1 . . . . . . . . . . . . . . . . . . . . . 3595.12.3 Structure of port 2 . . . . . . . . . . . . . . . . . . . . . 3595.12.4 Structure of port 3 . . . . . . . . . . . . . . . . . . . . . 360

5.13 Introduction to 8051 Programming . . . . . . . . . . . . . . . . . 3615.14 Addressing Modes . . . . . . . . . . . . . . . . . . . . . . . . . 3625.15 Instruction Set of 8051 . . . . . . . . . . . . . . . . . . . . . . . 363

5.15.1 Data transfer instructions . . . . . . . . . . . . . . . . . . 3635.15.2 Arithmetic instructions . . . . . . . . . . . . . . . . . . . 3675.15.3 Logical instructions . . . . . . . . . . . . . . . . . . . . . 3715.15.4 Bit level logical instructions . . . . . . . . . . . . . . . . 3735.15.5 Rotate and swap instructions . . . . . . . . . . . . . . . . 3755.15.6 Branching instructions . . . . . . . . . . . . . . . . . . . 377

5.16 Programming the 8051 . . . . . . . . . . . . . . . . . . . . . . . 382Short Question with Answers . . . . . . . . . . . . . . . . . . . 391

Page 10: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

Chapter 6 Interfacing Microcontroller 401 - 4716.1 External Memory Interfacing . . . . . . . . . . . . . . . . . . . . 401

6.1.1 Interfacing external program memory . . . . . . . . . . . 4016.1.2 Timing diagram for external program memory access . . . 4026.1.3 Instructions to access external ROM/EPROM . . . . . . . 4036.1.4 Interfacing external data memory . . . . . . . . . . . . . 4036.1.5 Timing diagram for external data memory access . . . . . 4046.1.6 Timing diagram for external data memory write operation 4056.1.7 Instruction to access external RAM . . . . . . . . . . . . 405

6.2 8051 Interrupts . . . . . . . . . . . . . . . . . . . . . . . . . . . 4066.2.1 Execution of an interrupt . . . . . . . . . . . . . . . . . . 4066.2.2 Interrupt sources . . . . . . . . . . . . . . . . . . . . . . 4066.2.3 Enabling & disabling interrupts . . . . . . . . . . . . . . 4086.2.4 Priority of the interrupts . . . . . . . . . . . . . . . . . . 4096.2.5 Timing of interrupts . . . . . . . . . . . . . . . . . . . . 4106.2.6 Level of the interrupts . . . . . . . . . . . . . . . . . . . 410

6.3 Timers and Counters . . . . . . . . . . . . . . . . . . . . . . . . 4106.3.1 Timer SFRs . . . . . . . . . . . . . . . . . . . . . . . . . 4116.3.2 Modes of operation . . . . . . . . . . . . . . . . . . . . . 4136.3.3 Timer control and operation . . . . . . . . . . . . . . . . 4166.3.4 Counter operation . . . . . . . . . . . . . . . . . . . . . . 4176.3.5 Programming examples . . . . . . . . . . . . . . . . . . 418

6.4 Serial Communication . . . . . . . . . . . . . . . . . . . . . . . 4186.4.1 Serial port control registers . . . . . . . . . . . . . . . . . 4196.4.2 Modes of operation . . . . . . . . . . . . . . . . . . . . . 4206.4.3 Programming the serial port for transmission . . . . . . . 4226.4.4 Programming the serial port for reception . . . . . . . . . 4236.4.5 Programming examples . . . . . . . . . . . . . . . . . . 424

6.5 Interfacing 8255 with 8051 . . . . . . . . . . . . . . . . . . . . . 4256.6 Interfacing Keyboard . . . . . . . . . . . . . . . . . . . . . . . . 426

6.6.1 Interfacing simple keyboard . . . . . . . . . . . . . . . . 4266.6.2 Interfacing matrix keyboard . . . . . . . . . . . . . . . . 427

6.7 Interfacing Displays . . . . . . . . . . . . . . . . . . . . . . . . . 4316.7.1 Interfacing seven segment LED displays . . . . . . . . . . 4316.7.2 Interfacing LCD display . . . . . . . . . . . . . . . . . . 433

6.8 Analog to Digital Converters (ADC) . . . . . . . . . . . . . . . . 4396.8.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . 4406.8.2 Successive approximation A/D converter . . . . . . . . . 4406.8.3 ADC 0808 / 0809 . . . . . . . . . . . . . . . . . . . . . . 441

Page 11: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari

6.8.4 Interfacing ADC 0808 with 8051 . . . . . . . . . . . . . 4436.9 Digital to Analog converter (DAC) . . . . . . . . . . . . . . . . . 444

6.9.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . 4456.9.2 Basic conversion techniques . . . . . . . . . . . . . . . . 4466.9.3 DAC 1408 . . . . . . . . . . . . . . . . . . . . . . . . . 4486.9.4 Interfacing DAC 1408 with microcontroller . . . . . . . . 4506.9.5 Programming applications . . . . . . . . . . . . . . . . . 451

6.10 DC Motor Interfacing . . . . . . . . . . . . . . . . . . . . . . . . 4536.10.1 Basic concepts . . . . . . . . . . . . . . . . . . . . . . . 4536.10.2 H - Bridge . . . . . . . . . . . . . . . . . . . . . . . . . 4546.10.3 L293 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4546.10.4 Interface of DC motor with 8051 . . . . . . . . . . . . . . 4546.10.5 Program to run the DC motor . . . . . . . . . . . . . . . 455

6.11 DC Motor Control using PWM . . . . . . . . . . . . . . . . . . . 4556.12 Stepper Motor Control . . . . . . . . . . . . . . . . . . . . . . . 457

6.12.1 Construction . . . . . . . . . . . . . . . . . . . . . . . . 4576.12.2 Sequences for rotation . . . . . . . . . . . . . . . . . . . 4586.12.3 Parameters . . . . . . . . . . . . . . . . . . . . . . . . . 4596.12.4 Types of stepper motors . . . . . . . . . . . . . . . . . . 4596.12.5 Interfacing stepper motor with 8051 . . . . . . . . . . . . 4606.12.6 Software . . . . . . . . . . . . . . . . . . . . . . . . . . 4606.12.7 Interfacing sensors . . . . . . . . . . . . . . . . . . . . . 462

6.13 Comparison of Microprocessor, Microcontroller, PIC and ARMProcessor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4636.13.1 Microprocessor and Microcontroller . . . . . . . . . . . . 4636.13.2 Difference between microprocessor and microcontroller . 4646.13.3 PIC microcontroller . . . . . . . . . . . . . . . . . . . . 4646.13.4 Advantages of PIC microcontroller . . . . . . . . . . . . 4656.13.5 Difference between PIC and 8051 microcontrollers . . . . 4656.13.6 ARM processor . . . . . . . . . . . . . . . . . . . . . . . 4656.13.7 Difference between ARM processor and other processors . 466Short Question with Answers . . . . . . . . . . . . . . . . . . . 466

Index 472 - 474

Page 12: Microprocessorscitechpublications.com/wp-content/uploads/2019/09/978... · 2019-09-11 · Microprocessor and Microcontroller Second Edition C. Latha Senior Lecturer (fmr) & B. Murugeshwari