Cover image for The 8051 microcontroller
Title:
The 8051 microcontroller
Personal Author:
Edition:
4th ed.
Publication Information:
Upper Saddle River, NJ : Prentice-Hall, 2007
ISBN:
9780130195623
Added Author:

Available:*

Library
Item Barcode
Call Number
Material Type
Item Category 1
Status
Searching...
30000010159408 TJ223.M53 M324 2007 Open Access Book Book
Searching...
Searching...
33000000001524 TJ223.M53 M324 2007 Open Access Book Gift Book
Searching...

On Order

Summary

Summary

For 8051 Microcontroller courses requiring a time tested and classroom proven textbook. MacKenzie's 8051 Microcontroller text emphasises the programming of the 8051 by illustrating the two most widely used programming methods; Assembly Language and C programming. This text assumes no prior knowledge of the subject and progressively introduces 8051 Microcontroller concepts while reinforcing those concepts with plenty of examples and exercies.


Table of Contents

1 Introduction to Microcontrollersp. 1
1.1 Introductionp. 1
1.2 Terminologyp. 3
1.3 The Central Processing Unitp. 4
1.4 Semiconductor Memory: RAM and ROMp. 5
1.5 The Buses: Address, Data, and Controlp. 6
1.6 Input/Output Devicesp. 7
1.6.1 Mass Storage Devices
1.6.2 Human Interface Devices
1.6.3 Control/Monitor Devices
1.7 Programs: Big and Smallp. 8
1.8 Micros, Minis, and Mainframesp. 9
1.9 Microprocessors vs. Microcontrollersp. 10
1.9.1 Hardware Architecture
1.9.2 Applications
1.9.3 Instruction Set Features
1.10 New Conceptsp. 12
1.11 Gains and Losses: A Design Examplep. 13
Problemsp. 14
2 Hardware Summaryp. 17
2.1 MCS-51 Family Overviewp. 17
2.2 Once Around the Pinsp. 18
2.2.1 Port 0
2.2.2 Port 1
2.2.3 Port 2
2.2.4 Port 3
2.2.5 PSEN (Program Store Enable)
2.2.6 ALE (Address Latch Enable)
2.2.7 EA (External Access)
2.2.8 RST (Reset)
2.2.9 On-Chip Oscillator Inputs
2.2.10 Power Connections
2.3 I/O Port Structurep. 22
2.4 Timing and the Machine Cyclep. 23
2.5 Memory Organizationp. 24
2.5.1 General-Purpose RAM
2.5.2 Bit-Addressable RAM
2.5.3 Register Banks
2.6 Special Function Registersp. 28
2.6.1 Program Status Word
2.6.2 B Register
2.6.3 Stack Pointer
2.6.4 Data Pointer
2.6.5 Port Registers
2.6.6 Timer Registers
2.6.7 Serial Port Registers
2.6.8 Interrupt Registers
2.6.9 Power Control Register
2.7 External Memoryp. 36
2.7.1 Accessing External Code Memory
2.7.2 Accessing External Memory
2.7.3 Address Decoding
2.7.4 Overlapping the External Code and Data Spaces
2.8 8032/8052 Enhancementsp. 41
2.9 Reset Operationp. 43
Summaryp. 44
Problemsp. 44
3 Instruction Set Summaryp. 49
3.1 Introductionp. 49
3.2 Addressing Modesp. 50
3.2.1 Register Addressing
3.2.2 Direct Addressing
3.2.3 Indirect Addressing
3.2.4 Immediate Addressing
3.2.5 Relative Addressing
3.2.6 Absolute Addressing
3.2.7 Long Addressing
3.2.8 Indexed Addressing
3.3 Instruction Typesp. 59
3.3.1 Arithmetic Instructions
3.3.2 Logical Instructions
3.3.3 Data Transfer Instructions
3.3.4 Boolean Instructions
3.3.5 Program Branching Instructions
Summaryp. 78
Problemsp. 78
4 Timer Operationp. 87
4.1 Introductionp. 87
4.2 Timer Mode Register (TMOD)p. 89
4.3 Timer Control Register (TCON)p. 89
4.4 Timer Modes and the Overflow Flagp. 90
4.4.1 13-Bit Timer Mode (Mode 0)
4.4.2 16-Bit Timer Mode (Mode 1)
4.4.3 8-Bit Auto-Reload Mode (Mode 2)
4.4.4 Split Timer Mode (Mode 3)
4.5 Clocking Sourcesp. 92
4.5.1 Interval Timing
4.5.2 Event Counting
4.6 Starting, Stopping, and Controlling the Timersp. 93
4.7 Initializing and Accessing Timer Registersp. 95
4.7.1 Reading a Timer "on the Fly"
4.8 Short, Medium, and Long Intervalsp. 96
4.9 Producing Exact Frequenciesp. 102
4.9.1 Eliminating Round-off Errors
4.9.2 Compensating for Overhead Due to Instructions
4.10 8052 Timer 2p. 105
4.10.1 Auto-Reload Mode
4.10.2 Capture Mode
4.11 Baud Rate Generationp. 106
Summaryp. 107
Problemsp. 107
5 Serial Port Operationp. 111
5.1 Introductionp. 111
5.2 Serial Communicationp. 111
5.3 Serial Port Buffer Register (SBUF)p. 112
5.4 Serial Port Control Register (SCON)p. 113
5.5 Modes of Operationp. 113
5.5.1 8-Bit Shift Register (Mode 0)
5.5.2 8-Bit UART with Variable Baud Rate (Mode 1)
5.5.3 9-Bit UART with Fixed Baud Rate (Mode 2)
5.5.4 9-Bit UART with Variable Baud Rate (Mode 3)
5.6 Full Duplex Serial Communication: Issuesp. 117
5.7 Initialization and Accessing Serial Port Registersp. 118
5.7.1 Receiver Enable
5.7.2 The Ninth Data Bit
5.7.3 Adding a Parity Bit
5.7.4 Interrupt Flags
5.8 Multiprocessor Communicationsp. 119
5.9 Serial Port Baud Ratesp. 120
5.9.1 Using Timer 1 as the Baud Rate Clock
Summaryp. 127
Problemsp. 128
6 Interruptsp. 131
6.1 Introductionp. 131
6.2 8051 Interrupt Organizationp. 132
6.2.1 Enabling and Disabling Interrupts
6.2.2 Interrupt Priority
6.2.3 Polling Sequence
6.3 Processing Interruptsp. 136
6.3.1 Interrupt Vectors
6.4 Program Design Using Interruptsp. 137
6.4.1 Small Interrupt Service Routines
6.4.2 Large Interrupt Service Routines
6.5 Timer Interruptsp. 139
6.6 Serial Port Interruptsp. 142
6.7 External Interruptsp. 143
6.8 Interrupt Timingsp. 148
Summaryp. 149
Problemsp. 150
7 Assembly Language Programmingp. 151
7.1 Introductionp. 151
7.2 Assembler Operationp. 152
7.2.1 Pass One
7.2.2 Pass Two
7.3 Assembly Language Program Formatp. 155
7.3.1 Label Field
7.3.2 Mnemonic Field
7.3.3 Operand Field
7.3.4 Comment Field
7.3.5 Special Assembler Symbols
7.3.6 Indirect Address
7.3.7 Immediate Data
7.3.8 Data Address
7.3.9 Bit Address
7.3.10 Code Address
7.3.11 Generic Jumps and Calls
7.4 Assemble-Time Expression Evaluationp. 160
7.4.1 Number Bases
7.4.2 Character Strings
7.4.3 Arithmetic Operators
7.4.4 Logical Operators
7.4.5 Special Operators
7.4.6 Relational Operators
7.4.7 Expression Examples
7.4.8 Operator Precedence
7.5 Assembler Directivesp. 164
7.5.1 Assembler State Control
7.5.2 Symbol Definition
7.5.3 Storage Initialization/Reservation
7.5.4 Program Linkage
7.5.5 Segment Selection Directives
7.6 Assembler Controlsp. 173
7.7 Linker Operationp. 173
7.8 Annotated Example: Linking Relocatable Segments and Modulesp. 176
7.8.1 ECHO.LST
7.8.2 IO.LST
7.8.3 Example.M51
7.9 Macrosp. 183
7.9.1 Parameter Passing
7.9.2 Local Labels
7.9.3 Repeat Operations
7.9.4 Control Flow Operations
Summaryp. 188
Problemsp. 188
8 8051 C Programmingp. 191
8.1 Introductionp. 191
8.2 Advantages and Disadvantages of 8051 Cp. 191
8.3 8051 C Compilersp. 192
8.4 Data Typesp. 193
8.5 Memory Types and Modelsp. 197
8.6 Arraysp. 198
8.7 Structuresp. 199
8.8 Pointersp. 199
8.8.1 A Pointer's Memory Type
8.8.2 Typed Pointers
8.8.3 Untyped Pointers
8.9 Functionsp. 202
8.9.1 Parameter Passing
8.9.2 Return Values
8.10 Some 8051 C Examplesp. 204
8.10.1 The First Program
8.10.2 Timers
8.10.3 Serial Port
8.10.4 Interrupts
Summaryp. 214
Problemsp. 214
9 Program Structure and Designp. 217
9.1 Introductionp. 217
9.2 Advantages and Disadvantages of Structured Programmingp. 219
9.3 The Three Structuresp. 220
9.3.1 Statements
9.3.2 The Loop Structure
9.3.3 The Choice Structure
9.4 Pseudo Code Syntaxp. 234
9.5 Assembly Language Programming Stylep. 237
9.5.1 Labels
9.5.2 Comments
9.5.3 Comment Blocks
9.5.4 Saving Registers on the Stack
9.5.5 The Use of Equates
9.5.6 The Use of Subroutines
9.5.7 Program Organization
9.6 8051 C Programming Stylep. 243
9.6.1 Comments
9.6.2 The Use of Defines
9.6.3 The Use of Functions
9.6.4 The Use of Arrays and Pointers
9.6.5 Program Organization
Summaryp. 245
Problemsp. 245
10 Tools and Techniques for Program Developmentp. 247
10.1 Introductionp. 247
10.2 The Development Cyclep. 247
10.2.1 Software Development
10.2.2 Hardware Development
10.3 Integration and Verificationp. 251
10.3.1 Software Simulation
10.3.2 Hardware Emulation
10.3.3 Execution from RAM
10.3.4 Execution from EPROM
10.3.5 The Factory Mask Process
10.4 Commands and Environmentsp. 255
Summaryp. 257
Problemsp. 257
11 Design and Interface Examplesp. 259
11.1 Introductionp. 259
11.2 The SBC-51p. 259
11.3 Hexadecimal Keypad Interfacep. 265
11.4 Interface to Multiple 7-Segment LEDsp. 267
11.5 Interface to Liquid Crystal Displays (LCDs)p. 273
11.6 Loudspeaker Interfacep. 276
11.7 Nonvolatile RAM Interfacep. 277
11.8 Input/Output Expansionp. 282
11.8.1 Using Shift Registers
11.8.2 Using the 8255
11.9 RS232 (EIA-232) Serial Interfacep. 291
11.10 Centronics Parallel Interfacep. 294
11.11 Analog Outputp. 296
11.12 Analog Inputp. 300
11.13 Interface to Sensorsp. 303
11.14 Interface to Relaysp. 306
11.15 Stepper Motor Interfacep. 310
Summaryp. 315
Problemsp. 315
12 Design and Interface Examples in Cp. 319
12.1 Introductionp. 319
12.2 Hexadecimal Keypad Interfacep. 319
12.3 Interface to Multiple 7-Segment LEDsp. 323
12.4 Interface to Liquid Crystal Displays (LCDs)p. 325
12.5 Loudspeaker Interfacep. 327
12.6 Nonvolatile RAM Interfacep. 329
12.7 Input/Output Expansionp. 333
12.8 RS232 (EIA-232) Serial Interfacep. 337
12.9 Centronics Parallel Interfacep. 339
12.10 Analog Outputp. 341
12.11 Analog Inputp. 342
12.12 Interface to Sensorsp. 344
12.13 Interface to Relaysp. 346
12.14 Stepper Motor Interfacep. 347
Problemsp. 350
13 Example Student Projectsp. 353
13.1 Introductionp. 353
13.2 Home Security Systemp. 353
13.2.1 Project Description
13.2.2 System Specifications
13.2.3 System Design
13.2.4 Software Design
13.3 Elevator Systemp. 355
13.3.1 Project Description
13.3.2 System Specifications
13.3.3 System Design
13.3.4 Software Design
13.4 Tic-Tac-Toep. 358
13.4.1 Project Description
13.4.2 System Specifications
13.4.3 Software Design
13.5 Calculatorp. 363
13.5.1 Project Description
13.5.2 System Specifications
13.5.3 Software Design
13.6 Micromousep. 366
13.6.1 Project Description
13.6.2 System Specifications
13.6.3 System Design
13.6.4 Software Design
13.7 A Soccer-Playing Robotp. 369
13.7.1 Project Description
13.7.2 System Specifications
13.7.3 System Design
13.7.4 Software Design
13.8 A Smart Card Applicationp. 371
13.8.1 Basic Security Concepts
13.8.2 Project Description
13.8.3 System Specifications
13.8.4 Software Design
Summaryp. 373
Problemsp. 374
14 8051 Derivativesp. 377
14.1 Introductionp. 377
14.2 MCS-151 and MCS-251p. 377
14.3 Microcontrollers with Flash Memory and NVRAMp. 377
14.4 Microcontrollers with ADCs and DACsp. 378
14.5 High-Speed Microcontrollersp. 378
14.6 Network Microcontrollersp. 379
14.7 Secure Microcontrollersp. 379
Summaryp. 379
Problemsp. 380
Appendices
A Quick Reference Chartp. 381
B Opcode Mapp. 383
C Instruction Definitionsp. 385
D Special Function Registersp. 431
E 8051 Data Sheetp. 439
F ASCII Code Chartp. 455
G MON51-An 8051 Monitor Programp. 457
H A Guide to Keil's [mu] Vision2 IDEp. 499
I A Guide to the 8052 Simulatorp. 507
J The Advanced Encryption Standardp. 515
K Sources of 8051 Development Productsp. 521
Bibliographyp. 527
Indexp. 529