Updated: 02.06.24

Main -> Books -> Technical Books -> My Books -> Programming and Customizing the 8051 Microcontroller

Cover of Programming and Customizing the 8051

Programming and Customizing the 8051 Microcontroller

"Programming and Customizing the 8051 Microcontroller" was chosen as the "Electronics Book of the Month Club" Main Selection for March 1999

The 8051 is a remarkable device in terms of the number of manufacturers and the wide range of devices and features available. 8051 compatible microcontrollers are available with anywhere from twenty pin embedded eight bit microcontrollers to multi-chip, high performance sixteen bit systems. The chips can just have straight digital I/O or highly sophisticated serial, bus, network input and output capabilities. The resulting wide range of potential applications can be intimidating to someone looking at the 8051 for the first time.

This Book/CD-ROM package was written to give a clear introduction to the 8051, both from a programming as well as a hardware interfacing point of view. Along with explaining the architecture, I also provide over thirty experiments that will help you to understand exactly how 8051 code and hardware applications are created.

The book also includes twelve example applications which will give you some "canned" device interfaces including:

Advanced programming techniques such as using the 8051 with Real Time Operating Systems and State Machines are also presented in the book with code that you can examine. The information provided in this 550 page book will give you all the information that you will need to start developing your own 8051 applications.

I find that the 8051 is one of the most difficult devices to find good "Freeware" or "Shareware" tools and programmers for. To help alleviate this problem; I have included, on the CD-ROM a demonstration copy of UMPS on the CD-ROM and the design for an Atmel 8051 compatible programmer in the book.

Rounding out the package, there is a number of code "snippets" that are designed to make your development efforts easier and provide you with a library of sixteen bit variable operations. Along with the book information, I have also included these snippets on my 8051 Web Page.

You can download Chapter 2 "8051 Processor Architecture" by clicking here. The file is 256K in size.


Table of Contents:

Acknowledgments

About the Author

Introduction
  The Intel 8051
  Additional Information and Resources
  Conventions used in this book

Microcontrollers
  Different types of microcontrollers
    Embedded Microcontrollers
    External Memory Microcontrollers
  Processor Architectures
    Harvard versus Princeton
    CISC versus RISC
  Microcontroller Memory Types
    Control Storage
    Variable Area
    Program Counter Stack
    Hardware Interface Registers (I/O Space)
  Microcontroller Features
    Clocking
    I/O Pins
    Interrupts
    Timers
    Peripherals
  The 8051
  8051 Suppliers

8051 Processor Architecture
  The CPU
  8051 Addressing Modes
  External Addressing
  Interrupts 
  8051 Instruction Execution

8051 Instruction Set
  Data Movement Instructions
  Bit Operators
  Execution Change Operators

8051 hardware features
  Device Packaging
  Chip Technologies
  Power Considerations
  Reset
  System clock/oscillators
  Parallel Input/Output
  Level Conversion
  Timers
  Serial I/O
  RS-232 Level Conversion
  Control Store
  External Memory Devices
  Ordering Information

Enhanced 8051 Features
  8051 Architecture Enhancements
    Intel MCS-151/251
    Dallas Semiconductor High-Speed Microcontrollers
  Contorl Store and External Memory
    Resizing Dallas Semiconductor HSM Control Store
    Adding Wait States to Dallas Semiconductor HSM Microcontrollers
    with External RAM
  Scratchpad RAM Enhancements
  Timers
    Dallas Semiconductor HSM Extensions
    TIMER2
    Dallas Semiconductor HSM Watchdog Timers
  Serial I/O
    Dallas Semiconductor HSM's Second Serial Port
    Microwire
    SPI
    I2C
    CAN
  Analog I/O
  Atmel AT89Cx051 Voltage Comparators

Application design
  Power input
  Reset
  System oscillators and clocks
  I/O Pin Interfacing
  Interrupts
  External RAM and ROM

8051 Programming
  8051 Programming
  Dallas Semiconductor DS8700 Programmer
  Atmel AT789Cx051 Programming
  PROG35: AT89Cx051 Programmer Circuit
  Dallas Semiconductor "Secure" Devices
    Microcontroller Programming

Software
  Development Tools/Environments
  Assembly Language
  8051 Assembly Language Programming Styles
  Interpreters
  High-Level Languages
  Intel Hex Format Object Files
  8051 Debugging Hints

Experiments with the 8051
  Tools and parts required
  PROG1: Setting up UMPS and getting a Program to Assemble
  PROG2: Arithmetic Operations
  PROG3: Direct Bank Register Addressing
  PROG4: Indirect Bank Register Addressing
  PROG6: RAM Direct Addressing
  PROG7: Bit Addressing
  PROG8: The DPTR Pointer Register and External Memory
  PROG5: Jumping Around and Control Store Pages
  PROG9: Conditional Branching
  PROG10: Loop Control
  PROG11: Stack Operations
  PROG12: Stack Arithmetic Operations
  PROG13: Subroutines
  PROG14: Register Parameter Passing
  PROG15: Stack Parameter Passing
  PROG16: Implementing Variable Arrays
  PROG17: Control Store Tables
  PROG18: State Machines
  PROG1: Running a Program in Hardware
  PROG19: Polling a button
  PROG45: Inadvertently Changing an I/O Bit
  PROG20: Button Debouncing
  PROG21: Christmas Lights
  PROG34: Oscillators
  PROG34: Decoupling Capacitors and Power Supplies
  PROG22: Reset
  PROG23: RAM Contents on Power Up
  PROG24: Timer Interrupts with Context Saving
  PROG25: Timer Interrupts without Context Saving
  PROG26: Button Debouncing using Interrupts and Timer
  PROG27: Memory-Mapped I/O
  PROG28: External Memory
  In Closing

Emulators
  Types of Emulators
  Monitor Programs
  PROG29: AT89Cx051 monitor/emulator using the DS87C520

Real-Time Operating Systems
  RTOS Basics
  PROG30: 8051 Example RTOS
    PROG30: RTOSLite
    PROG31: FullRTOS
    LCD Digital Clock/Thermometer using FullRTOS

Example Applications
  Marya's Music Box
  PROG36: 51Bot - Getting the Wheels Turning
  PROG37: 51Bot - Remote Operation with I/R TV Remote Control
  PROG41: 51Bot - RS-232 Interface
  PROG42: 51Bot - PWM Motor Control
  51Bot: Embedded Card
  PROG33: Aircraft Control Demonstration
  PROG39: Light Sensors for Robots
  PROG38: Ultrasonic Distance Measuring
  PROG49: NTSC Compatible Video Output
  PROG47: Electronic RS-232 "Breakout Box"

Epilogue

Appendix A - Glossary

Appendix B - 8051 Resources
  Contacting the Author
  8051 Suppliers
  Part Suppliers
  Periodicals
  Web Resources
  Consultants and Product Suppliers

Appendix C - 16-Bit Operations
  Declaring 16-Bit Variables
  Incrementing and Decrementing
  Addition, Subtraction and Bit Operations
  Multiplication
  Division

Appendix D - Useful Routines
  Timing Delays
  Table Operations
  LCD Interfaces
  I2C Bus Master Interface
  "Bit Banking" Asynchronous Serial Interface
  Hex to ASCII conversion
  Sorting Numbers
  Loading the "Encryption Array"
  Circular Buffers

Appendix E - UMPS

Appendix F - SimmStick

Appendix G - Remote 8051 Debugger

Appendix H - The CD-ROM

Appendix I - PROG50: Ordering Raw Cards and Kits

Index

            

ISBN Numbers

Softcover: 0-07-134192-7
            

Errata:

This book seems quite "clean", but as you would expect there are a few problems that have creeped in. These errors will be corrected in subsequent printings of the book:

  1. I haven't specified explicitly where the raw card "Gerbers" can be found. They are located in:
    \code\prog50
                    
    of the CD-ROM. With the Gerber Files for the top side, bottom side and overlay, I have also included the aperture files, drill and tooling files for the cards (which are placed in one image and can be cut apart).

    Please let me know if you are looking for pre-built sources for the cards.

  2. Note that "UMPS" and the application source should be copied onto your PC's hard drive. I've had a couple of complaints from people saying that while UMPS can run from the CD-ROM, they couldn't assemble the source files. To avoid this problem, make sure that your Source Files are copied onto your hard drive.
  3. Throughout the book, anytime a register is specified with more than one bit and I've grouped the bits together, the order of the bit listing (on the left side of the table) is reversed.
  4. On Page 53. For some reason "Von Neumann" got changed to "VGA Neumann". This happened somewhere in the final production process.

These problems will be corrected in the next and subsequent printings of the book. If you find anything else, please let me know,

myke