Book's TOC

PREFACE TO THIS EDITION

PREFACE

1    EMBEDDED SYSTEMS
1.1    Objectives
1.2    Introduction
1.3    Computers in Everyday Life
1.4    Implementing the Process Stage
    1.4.1    Using Discrete Digital Logic or Programmable Logic Devices
    1.4.2    Using Custom VLSI Solutions
    1.4.3    Using Microprocessors and Microcontrollers
1.5 Embedded Computer versus General Purpose Computer
1.6 Summary
1.7 Questions

2    MICROPROCESSORS AND MICROCONTROLLER
2.1    Objectives
2.2    Introduction
2.3    Microprocessors and Microcontrollers
    2.3.1    Microprocessors
    2.3.2    Microcontrollers
    2.3.3    Comparing Microprocessors and Microcontrollers
    2.3.4    The Z80 and the 8051
2.4    Four-Bit to Thirty-Two-Bit Microcontrollers
    2.4.1    Four-Bit Microcontrollers
    2.4.2    Eight-Bit Microcontrollers
    2.4.3    Sixteen-Bit Microcontrollers
    2.4.4    Thirty-Two-Bit Microcontrollers
2.5    Development Tools for Microcontrollers
    2.5.1    Assembler
    2.5.2    Compiler
    2.5.3    Simulator/Debugger
    2.5.4    E(E)PROM or Flash Memory Programmer
    2.5.5    Logic Analyzer 24
2.6    Summary 25
2.7    Questions 25

3    NUMBERING SYSTEMS AND ARITHMETIC
3.1    Objectives
3.2    Introduction
3.3    Symbolic Number Systems
3.4    Positional Number Systems
3.5    Integer Binary Numbers
    3.5.1    Binary Digital Computers
    3.5.2    The Binary Number System
    3.5.3    Conversions between Decimal and Binary Numbers
    3.5.4    Hexadecimal Numbers
    3.5.5    Conversions between Hexadecimal, Binary, and Decimal Numbers
3.6    Fractional Binary Numbers
    3.6.1    Converting Binary Fractions to Decimal
    3.6.2    Converting Hexadecimal Fractions to Decimal
    3.6.3    Converting Decimal Fractions to Binary and Hexadecimal
3.7    Number System Notation
3.8    Binary Addition and Subtraction
    3.8.1    Binary Number Addition and Subtraction
    3.8.2    Signed Binary Numbers
    3.8.3    Complementary Numbers
    3.8.4    Two’s Complement Mathematics
3.9    Binary Multiplication and Division
    3.9.1    Binary Multiplication
    3.9.2    Binary Division
3.10    Binary Codes
    3.10.1    Character Codes
    3.10.2    Numeric Codes
    3.10.3    Other Binary Codes
    3.10.4    Error Correction and Detection Codes
3.11    Summary
3.12    Questions

4    THE 8051 ARCHITECTURES

4.1    Objectives
4.2    Introduction
4.3    8051 Microcontroller Hardware
    4.3.1    The 8051 Oscillator and Clock
    4.3.2    Program Counter and Data Pointer
    4.3.3    A and B CPU Registers
    4.3.4    Flags and the Program Status Word (PSW)
    4.3.5    Internal Memory
    4.3.6    Internal RAM
    4.3.7    The Stack and the Stack Pointer
    4.3.8    Special Function Registers
    4.3.9    Internal ROM
4.4    Input/Output Pins, Ports, and Circuits
    4.4.1    Port 0
    4.4.2    Port 1
    4.4.3    Port 2
    4.4.4    Port 3
4.5    External Memory
    4.5.1    Connecting External Memory
4.6    Counters and Timers
    4.6.1    Timer Counter Interrupts
    4.6.2    Timing
    4.6.2    Timer Modes of Operation
    4.6.3    Counting
4.7    Serial Data Input/Output
    4.7.1    Serial Data Interrupts
    4.7.2    Data Transmission
    4.7.3    Data Reception
    4.7.4    Serial Data Transmission Modes
4.8    Interrupts
    4.8.1    Timer Flag Interrupt
    4.8.2    Serial Port Interrupt
    4.8.3    External Interrupts
    4.8.4    Reset
    4.8.5    Interrupt Control
    4.8.6    Interrupt Priority
    4.8.7    Interrupt Destinations
    4.8.8    Software-Generated Interrupts
4.9    Summary
4.10    Questions

5    ASSEMBLY LANGUAGE PROGRAMMING CONCEPT
5.1    Objectives
5.2    The Forest and the Trees
5.3    A Generic Computer
    5.3.1    Hardware Concepts: The Central Processing Unit
    5.3.2    Hardware Concepts: Memory
    5.3.3    Software Concepts: Code and Data Memory
    5.3.4    Computer Concepts: A Computer Model
    5.3.5    Computer Concepts: Starting Up
    5.3.6    Computer Concepts: Machine Language
    5.3.7    Software Concepts: Assembly Language Mnemonics
5.4    The Mechanics of Programming
    5.4.1    Getting Instructions into Code Memory
    5.4.2    Computer Languages
    5.4.3    Why Use Assembly Language?
5.5    The Assembly Language Programming Process
5.6    The PAL Practice CPU
    5.6.1    PAL Instructions
5.7    Programming Tools and Techniques
    5.7.1    Understanding Assembly Language Syntax
    5.7.2    Understanding the Assembler Program
    5.7.3    Understanding the Problem to Be Solved
    5.7.4    Designing the Program
    5.7.5    Flow Charts
    5.7.6    Writing and Testing the Program
5.8    Programming the 8051
    5.8.1    Lines of Code
    5.8.2    8051 Instruction Syntax
5.9    Summary
5.10    Questions

6    MOVING DATA
6.1    Objectives
6.2    Introduction
6.3    Addressing Modes
    6.3.1    Immediate Addressing Mode
    6.3.2    Register Addressing Mode
    6.3.3    Direct Addressing Mode
    6.3.4    Indirect Addressing Mode
6.4    External Data Moves
6.5    Code Memory Read-Only Data Moves
6.6    Push and Pop Opcodes
6.7    Data Exchanges
6.8    Example Problems
6.9    Summary
6.10    Questions

7    LOGICAL OPERATIONS
7.1    Objectives
7.2    Introduction
7.3    Byte-Level Logical Operations
7.4    Bit-Level Logical Operations
    7.4.1    Internal RAM Bit Addresses
    7.4.2    SFR Bit Addresses
    7.4.3    Bit-Level Boolean Operations
7.5    Rotate and Swap Operations
7.6    Example Problems
7.7    Summary
7.8    Questions

8    ARITHMETIC OPERATIONS
8.1    Objectives
8.2    Introduction
8.3    Flags
    8.3.1    Instructions Affecting Flags
8.4    Incrementing and Decrementing
8.5    Addition
    8.5.1    Unsigned and Signed Addition
    8.5.2    Unsigned Addition
    8.5.3    Signed Addition
    8.5.4    Multiple-Byte Signed Arithmetic
8.6 Subtraction
    8.6.1    Unsigned and Signed Subtraction
    8.6.2    Unsigned Subtraction
    8.6.3    Signed Subtraction
8.7    Multiplication and Division
    8.7.1    Multiplication
    8.7.2    Division
8.8    Decimal Arithmetic
8.9    Example Problems
8.10    Summary
8.11    Questions

9    JUMP AND CALL INSTRUCTIONS
9.1    Objectives
9.2    Introduction
9.3    The Jump and Call Program Range
    9.3.1    Relative Range
    9.3.2    Short Absolute Range
    9.3.3    Long Absolute Range
9.4    Jumps
    9.4.1    Bit Jumps
    9.4.2    Byte Jumps
    9.4.3    Unconditional Jumps
9.5    Calls and Subroutines
    9.5.1    Subroutines
    9.5.2    Calls and the Stack
    9.5.3    Calls and Returns
9.6 Interrupts and Returns
9.7 More Detail on Interrupts
    9.7.1    The Interrupt Enable (IE) Special Function Register
    9.7.2    The Enable All Interrupts (EA) Bit
    9.7.3    Individual Interrupt Enable Bits
    9.7.4    The Interrupt Priority (IP) Special Function Register
    9.7.5    Ties
    9.7.6    Interrupts and Interrupt Handler Subroutines
    9.7.7    The Fine Print
    9.7.8    In Conclusion
9.8    Example Problems
9.9    Summary
9.10    Questions

10    AN 8051 MICROCONTROLLER DESIGN
10.1    Objectives
10.2    Introduction
10.3    A Microcontroller Specification
10.4    A Microcontroller Design
    10.4.1    External Memory and Memory Space Decoding
    10.4.2    Reset and Clock Circuits
    10.4.3    Expanding I/O
    10.4.4    Memory-Mapped I/O
    10.4.5    Memory Address Decoding
    10.4.6    Part Speed
    10.4.7    Memory Access Times
    10.4.8    Production Concerns
10.5    Testing the Design
    10.5.1    Crystal Test
    10.5.2    ROM Test
    10.5.3    RAM Test
10.6    Timing Subroutines
    10.6.1    Time Delays
    10.6.2    Pure Software Time Delay
    10.6.3    Software-Polled Timer
    10.6.4    Pure Hardware Delay
10.7    Lookup Tables for the 8051
    10.7.1    PC as a Base Address
    10.7.2    DPTR as a Base Address
10.8    Serial Data Transmission
    10.8.1    Character Transmission Using a Time Delay
    10.8.2    Character Transmission by Polling
    10.8.3    Interrupt-Driven Character Transmission
    10.8.4    Receiving Serial Data
    10.8.5    Polling for Received Data
    10.8.6    Interrupt-Driven Data Reception
10.9 Summary
10.10 Questions

11    APPLICATIONS
11.1    Objectives
11.2    Introduction
11.3    Keyboards
    11.3.1    Human Factors
    11.3.2    Key Switch Factors
    11.3.3    Keyboard Configurations
    11.3.4    Programs for Keyboards
    11.3.5    A Scanning Program for Small Keyboards
    11.3.6    Interrupt-Driven Programs for Small Keyboards
    11.3.7    Program for a Large Matrix Keyboard
11.4    Displays
    11.4.1    Seven-Segment Numeric Display
    11.4.2    Intelligent LCD Display
11.5    Pulse Measurement
    11.5.1    Measuring Frequency
    11.5.2    Pulse Width Measurement
11.6    D/A and A/D Conversions
    11.6.1    D/A Conversions
    11.6.2    A/D Conversion
11.7    Multiple Interrupts
    11.7.3    Hardware Circuits for Multiple Interrupts
11.8    Putting It All Together
11.9    Summary
11.10    Questions

12    SERIAL DATA COMMUNICATION
12.1    Objectives
12.2    Introduction
12.3    Network Configurations
12.4    8051 Data Communication Modes Example Programs
    12.4.1    Mode 0: Shift Register Mode
    12.4.2    Mode 1: Standard 8-Bit UART Mode
    12.4.3    Modes 2 and 3: Multiprocessor
12.5    Summary
12.6    Questions

13 THE MOST POPULAR 8051s
13.1    Objectives
13.2    Introduction
13.3    The 8052
    13.3.1    Capture Timers
    13.3.2    T2 Software Additions
    13.3.3    Timer T2 Interrupt
    13.3.4    Uses for Timer 2
13.4    Faster and Smaller
    13.4.1    Faster
    13.4.2    Fastest
    13.4.3    Smaller
13.5    Bigger
    13.5.1    The XA Family
    13.5.2    RAM
    13.5.3    ROM
    13.5.4    The 80251
13.6    Advanced peripherals on new 8051 variants
    13.6.1    Analog to Digital Converter
    13.6.2    Digital to Analog Converter
    13.6.3    Analog Comparator
    13.6.4    Watchdog Timer
    13.6.5    Real Time Clock
    13.6.6    Pulse Width Modulation
    13.6.7    Inter-Integrated Circuit Bus
    13.6.8    Serial Peripheral Interconnect Bus
    13.6.9    Controller Area Network Bus
    13.6.10    Ethernet
    13.6.11    USB
    13.6.12    RF Link
    13.6.13    Other Features and Enhancements
13.7    AT89C51: The Original Descendant
    13.7.1    Pin Out and Architecture
    13.7.2    Features of AT89C51’s Flash Memory
    13.7.3    Programming the AT89C51’s Flash Memory
13.8    AT89C2051: The Baby 8051
    13.8.1    Pinout and Architectur
    13.8.2    Special Characteristics
    13.8.3    Flash Memory Programming
    13.8.4    Sample Application: Multiplexed Display
13.9    P89V51RD2: The Versatile Workhorse
    13.9.1    Pinout and Architecture
    13.9.2    Special Characteristics
13.10    8052-BASIC: BASIC on a Chip
    13.10.1    Pinout and Architecture
    13.10.2    8052-BASIC: Commands and Statements
    13.10.3    Loading Assembly Language Routines
    13.10.4    Sample 8052-BASIC System
13.11    Summary
13.12    Questions

14    C PROGRAMMING
14.1    Objectives
14.2    Introduction
14.3    Embedded C
    14.3.1    Super Loops
    14.3.2    Storage Classes
    14.3.3    Absolute Addressing
    14.3.4    Memory Models
    14.3.5    Compiler Options and Outputs
    14.3.6    Bits
    14.3.7    Interrupts in C
    14.3.8    Mixing Assembly with C
14.4    Summary
14.5    Questions

15    LAB EXERCISES USING THE UNI-51-SDK
15.1    Objectives
15.2    Introduction
15.3    Lab Exercise 1: Blink those LEDs!
15.4    Lab Exercise 2: Reading Switches
15.5    Lab Exercise 3: Brightness control of LEDs using PWM
15.6    Lab Exercise 4: – Serial Communications
15.7    Lab Exercise 5:—Calculator
15.8    Lab Exercise 6: Digital Clock
15.9    Lab Exercise 7 – Digital Thermostat
15.10    Exercises for Practice

APPENDIX A    8051 OPERATIONAL CODE MNEMONICS
A.1    Introduction
A.2    Mnemonics, Arranged by Function
    Arithmetic
    Logic
    Data Moves
    Calls and Jumps
    Boolean
A.3    Mnemonics, Arranged Alphabetically
    Mnemonic Acronyms
A.4    Intel Corporation Mnemonics, Arranged Alphabetically
    Acronyms
A.5    8051 Instruction Hexadecimal Codes

APPENDIX B    CONTROL REGISTERS
B.1    Introduction
B.2    Control Special-Function Register Figures
B.3    Internal RAM and SFR Addresses
B.4    ASCII Codes for Text and Control Characters—No Parity

APPENDIX C    THE 8255 PROGRAMMABLE I/O PORT
C.1    Introduction
C.2    Functional Description
    Addressing the 8255
C.3    Programming the 8255
    8255 I/O Modes
    Reset Condition

APPENDIX D    USING KEIL’S C51 TOOLS
D.1    Introduction
D.2    Installing Keil’s C51 Tools
D.3    Keil’s A51 Assembler
    The Big Picture
    Assembler Directives
    Numbers
    Labels
    Reserved Symbols as Labels
    Uppercase and Lowercase
D.4    Using µVision3 IDE
D.5    Running the program on real hardware
D.6    C Programming using Keil C51 Tools

APPENDIX E    USING SDCC & FLASHMAGIC
E.1    Introduction
E.2    Installation
    Step 1 – Installing SDCC
    Step 2 – Installing Java Runtime Environment
    Step 3 – Installing Eclipse
    Step 4 – Installing EclipseSDCC
    Step 5 – Installing FlashMagic
Developing an application

APPENDIX F    THE UNI-51-SDK
F.1    Introduction
F.2    Various Sections of the UNI-51-SDK Experimentation Board
F.3    Contents of the UNI-51-SDK Package
F.4    Supported Microcontrollers
F.5    Schematics of UNI-51-SDK Experimentation Board

INDEX
Comments