Microcontroller Programming

Book description

Written to help readers better understand the essentials of microcontroller programming, this textbook combines theory and practical examples to present concepts in a way that both students and professionals will find useful. It begins with the introduction of basic electronics, followed with coverage of microcontroller hardware and interfacing devices. It then addresses fundamental microcontroller programming techniques and advanced topics such as interfacing and programmable timer operations. Focusing on Motorola 68HC11 microcontroller, numerous flowcharts illustrate step-by-step procedures, and full-length projects provide practical problem solving approaches, with examples that portray real-life scenarios. An accompanying website provides video tutorials and additional information.

Table of contents

  1. Cover
  2. Half Title
  3. Title Page
  4. Copyright Page
  5. Dedication
  6. Table of Contents
  7. Preface
  8. Acknowledgments
  9. The Author
  10. 1. Number Systems, Operations, and Codes
    1. 1.1 Introduction
    2. 1.2 Digital versus Analog Quantities
    3. 1.3 Digital Numbering System (Base 10)
    4. 1.4 Binary Numbering System (Base 2)
    5. 1.5 Octal Numbering System (Base 8)
    6. 1.6 Hexadecimal Numbering System (Base 16)
    7. 1.7 Binary-Coded-Decimal System
    8. 1.8 Binary Conversions
    9. 1.9 Binary Operations
      1. 1.9.1 Binary Addition
      2. 1.9.2 Binary Subtraction
      3. 1.9.3 Binary Multiplication
      4. 1.9.4 Binary Division
    10. 1.10 Octal Conversions
    11. 1.11 Hexadecimal Conversions
    12. 1.12 Hexadecimal Operations
      1. 1.12.1 Hexadecimal Addition
      2. 1.12.2 Hexadecimal Subtraction
    13. 1.13 1’s and 2’s Complements of Binary Numbers
      1. 1.13.1 Finding the 1’s Complement
      2. 1.13.2 Finding the 2’s Complement
    14. 1.14 Signed Numbers
      1. 1.14.1 The Sign Bit
      2. 1.14.2 Sign-Magnitude Form
      3. 1.14.3 1’s Complement Form
      4. 1.14.4 2’s Complement Form
    15. 1.15 The ASCII Code
    16. 1.16 Summary
    17. Glossary
    18. Answers to Section Review Quiz
    19. True/False Quiz
    20. Questions
    21. Problems
  11. 2. Semiconductors and Digital Logic
    1. 2.1 Introduction
    2. 2.2 Diode Logic
    3. 2.3 The Inverter
      1. 2.3.1 Inverter Truth Table
      2. 2.3.2 Inverter Symbol
      3. 2.3.3 Operation of an Inverter
      4. 2.3.4 Timing Diagrams
      5. 2.3.5 Logic Expressions for an Inverter
    4. 2.4 The AND Gate
      1. 2.4.1 AND Gate Symbol
      2. 2.4.2 Operation of an AND Gate
      3. 2.4.3 AND Gate Truth Table
      4. 2.4.4 Timing Diagrams
      5. 2.4.5 Logic Expressions for an AND Gate
    5. 2.5 The OR Gate
      1. 2.5.1 OR Gate Symbol
      2. 2.5.2 Operation of an OR Gate
      3. 2.5.3 OR Gate Truth Table
      4. 2.5.4 Timing Diagram
      5. 2.5.5 Logic Expressions for an OR Gate
    6. 2.6 The NAND Gate
      1. 2.6.1 NAND Gate Symbol
      2. 2.6.2 Operation of a NAND Gate
      3. 2.6.3 Timing Diagram
      4. 2.6.4 Negative-OR Equivalent Operation of a NAND Gate
      5. 2.6.5 Logic Expressions for a NAND Gate
    7. 2.7 The NOR Gate
      1. 2.7.1 NOR Gate Symbol
      2. 2.7.2 Operation of a NOR Gate
      3. 2.7.3 Timing Diagram
      4. 2.7.4 Negative-AND Equivalent Operation of the NOR Gate
      5. 2.7.5 Logic Expressions for a NOR Gate
    8. 2.8 The Exclusive-OR Gate
      1. 2.8.1 XOR Gate Symbol
      2. 2.8.2 Operation of XOR Gate
      3. 2.8.3 XOR Gate Truth Table
      4. 2.8.4 Timing Diagram
      5. 2.8.5 Parity
        1. 2.8.5.1 Odd-Parity Generator
    9. 2.9 The Exclusive-NOR Gate
      1. 2.9.1 XNOR Gate Symbol
      2. 2.9.2 Operation of XNOR Gate
      3. 2.9.3 XNOR Gate Truth Table
      4. 2.9.4 Timing Diagram
    10. 2.10 Summary
    11. Glossary
    12. Answers to Section Review Quiz
    13. True/False Quiz
    14. Questions
    15. Problems
  12. 3. Microcontroller Hardware
    1. 3.1 Introduction
    2. 3.2 A Transistor as a Switch
    3. 3.3 The TTL Integrated Circuit
    4. 3.4 The CMOS Integrated Circuit
    5. 3.5 Using Integrated-Circuit Logic Gates
    6. 3.6 Seven-Segment Displays
    7. 3.7 Liquid-Crystal Displays
    8. 3.8 Keypads
    9. 3.9 The 68HC11/68HC12 Microcontroller
      1. 3.9.1 HC11 Processor
      2. 3.9.2 HC11 Memory
        1. 3.9.2.1 RAM
        2. 3.9.2.2 ROM
        3. 3.9.2.3 EEPROM
        4. 3.9.2.4 System Registers
      3. 3.9.3 HC11 Advanced On-Chip Input/Output (I/O) Capabilities
    10. 3.10 EVBU/BUFFALO
    11. 3.11 Summary
    12. Glossary
    13. Answers to Section Review Quiz
    14. True/False Quiz
    15. Questions
    16. Problems
  13. 4. Microcontroller Software
    1. 4.1 Introduction
    2. 4.2 Programming Concepts
    3. 4.3 System Software
    4. 4.4 Developing a Program
      1. 4.4.1 Problem Analysis
      2. 4.4.2 Design Development
      3. 4.4.3 Coding
      4. 4.4.4 Program Testing
    5. 4.5 Flow and State Diagrams
      1. 4.5.1 Flowchart Symbols
      2. 4.5.2 Flowcharting Techniques
      3. 4.5.3 State Diagrams
    6. 4.6 HC11 Programming Model
      1. 4.6.1 The Condition Code Register (Flags)
        1. 4.6.1.1 Zero Flag (Z)
        2. 4.6.1.2 Negative Flag (N)
        3. 4.6.1.3 Carry Flag (C)
        4. 4.6.1.4 Overflow Flag (V)
        5. 4.6.1.5 Interrupt Mask Flag (I)
        6. 4.6.1.6 Nonmaskable Interrupt Flag (X)
        7. 4.6.1.7 Half-Carry Flag (H)
        8. 4.6.1.8 Stop Disable Flag (S)
    7. 4.7 HC11 Memory-Addressing Modes
      1. 4.7.1 Extended Addressing
      2. 4.7.2 Direct Addressing
      3. 4.7.3 Immediate Addressing
      4. 4.7.4 Inherent Addressing
      5. 4.7.5 Indexed Addressing
      6. 4.7.6 Relative Addressing
    8. 4.8 Summary
    9. Glossary
    10. Answers to Section Review Quiz
    11. True/False Quiz
    12. Questions
    13. Problems
  14. 5. Instructions
    1. 5.1 Introduction
    2. 5.2 Data Movement
      1. 5.2.1 Load Instructions
      2. 5.2.2 Store Instructions
      3. 5.2.3 Clear Instructions
      4. 5.2.4 Transfer Instructions
      5. 5.2.5 Exchange Instructions
    3. 5.3 Arithmetic
      1. 5.3.1 Addition
      2. 5.3.2 Increment Instructions
      3. 5.3.3 Subtraction
      4. 5.3.4 Negate and Decrement Instructions
    4. 5.4 Logic
    5. 5.5 Shifting and Rotating
    6. 5.6 Multiplication and Division
    7. 5.7 CCR (Flag) Manipulation
    8. 5.8 Bit-Level Operations
    9. 5.9 Summary
    10. Glossary
    11. Answers to Section Review Quiz
    12. True/False Quiz
    13. Questions
    14. Problems
  15. 6. Control Structures and Subroutines
    1. 6.1 Introduction
    2. 6.2 Indexed Addressing Mode
    3. 6.3 Jumping and Branching
      1. 6.3.1 Jumping
      2. 6.3.2 Branching
        1. 6.3.2.1 Relative Addressing versus Absolute Addressing
        2. 6.3.2.2 Conditional and Unconditional Branching
    4. 6.4 Compare Instructions
    5. 6.5 Conditional Flow and Program Loops
    6. 6.6 Stack Operation
    7. 6.7 Subroutines
    8. 6.8 BUFFALO Subroutine
    9. 6.9 Summary
    10. Glossary
    11. Answers to Section Review Quiz
    12. True/False Quiz
    13. Questions
    14. Problems
  16. 7. Hello World!
    1. 7.1 Introduction
    2. 7.2 Creating Source Code Files
      1. 7.2.1 Writing the “Hello World!” Program
    3. 7.3 Assembling Programs
    4. 7.4 Ten Useful Programs
    5. 7.5 Summary
    6. Glossary
    7. Answers to Section Review Quiz
    8. True/False Quiz
    9. Questions
    10. Problems
  17. 8. Input/Output (I/O) Ports
    1. 8.1 Introduction
    2. 8.2 Data Transfer Mode
    3. 8.3 Port A
    4. 8.4 Port B
    5. 8.5 Port C
    6. 8.6 Port D and Port E
    7. 8.7 I/O Using Handshaking
      1. 8.7.1 Simple Handshaking
      2. 8.7.2 Full-Input Handshaking
      3. 8.7.3 Full-Output Handshaking
    8. 8.8 A Project Using Port B
      1. 8.8.1 Objective
      2. 8.8.2 Requirements Analysis
      3. 8.8.3 Design Development
    9. 8.9 Summary
    10. Glossary
    11. Answers to Section Review Quiz
    12. True/False Quiz
    13. Questions
    14. Problems
  18. 9. Interrupts
    1. 9.1 Introduction
    2. 9.2 Basics of an Interrupt
    3. 9.3 Servicing an Interrupt
    4. 9.4 Interrupt Control
      1. 9.4.1 Interrupt Related Instructions
      2. 9.4.2 Local and Global Control
    5. 9.5 Maskable Interrupts
      1. 9.5.1 Serial Communication System Interrupt Sources
      2. 9.5.2 Timer System Interrupt Sources
      3. 9.5.3 External Interrupts Using IRQ
      4. 9.5.4 Maskable Interrupt Priority
    6. 9.6 Output Compare
      1. 9.6.1 Internal Timing Devices
      2. 9.6.2 Output Compare Interrupts
        1. 9.6.2.1 Output-Compare Registers
        2. 9.6.2.2 Dedicated Comparators
    7. 9.7 Nonmaskable Interrupts
      1. 9.7.1 External Interrupts Using XIRQ
      2. 9.7.2 Other Nonmaskable Interrupts
    8. 9.8 Interrupts on the EVBU
    9. 9.9 A Project with Interrupts
      1. 9.9.1 Objective
      2. 9.9.2 Requirements Analysis
      3. 9.9.3 Design
      4. 9.9.4 Description of OC3 ISR
    10. 9.10 Summary
    11. Glossary
    12. Answers to Section Review Quiz
    13. True/False Quiz
    14. Questions
    15. Problems
  19. 10. Analog Capture
    1. 10.1 Introduction
    2. 10.2 Analog-to-Digital Conversion
      1. 10.2.1 Range
      2. 10.2.2 Steps
      3. 10.2.3 Step Voltage and Digital Code
      4. 10.2.4 Resolution
    3. 10.3 A/D Tools
      1. 10.3.1 Port E
      2. 10.3.2 ADC
      3. 10.3.3 Conversion Control
      4. 10.3.4 Result Registers
    4. 10.4 A/D Operation
    5. 10.5 A Project with Analog Capture
      1. 10.5.1 Requirements Analysis
      2. 10.5.2 Hardware Design
      3. 10.5.3 Software Design
    6. 10.6 Summary
    7. Glossary
    8. Answers to Section Review Quiz
    9. True/False Quiz
    10. Questions
    11. Problems
  20. 11. Input Capture
    1. 11.1 Introduction
    2. 11.2 Basic Modules of Input Capture
    3. 11.3 Input-Capture Registers
    4. 11.4 Input Edge Detection Logic
    5. 11.5 Interrupt Generation Logic
    6. 11.6 A Project with Input Capture
    7. 11.7 Summary
    8. Glossary
    9. Answers to Section Review Quiz
    10. True/False Quiz
    11. Questions
    12. Problems
  21. 12. Higher-Level Programming
    1. 12.1 Introduction
    2. 12.2 Levels in Programming Languages
    3. 12.3 C Programming
      1. 12.3.1 Getting Started with C
      2. 12.3.2 Data Types
      3. 12.3.3 Operators
      4. 12.3.4 Conditional Flow and Program Loops
      5. 12.3.5 Subroutines
      6. 12.3.6 Pointers and Arrays
    4. 12.4 Examples
    5. 12.5 A Project with C
    6. 12.6 Summary
    7. Glossary
    8. Answers to Section Review Quiz
    9. True/False Quiz
    10. Questions
    11. Problems
  22. Appendix 1—Supplemental Web Site
  23. Appendix 2—States and Resolution for Binary Numbers
  24. Appendix 3—Basic Boolean Theorems and Identities
  25. Appendix 4—The Resistor Color Code
  26. Appendix 5—Waterfall Software Development Lifecycle Model
  27. Appendix 6—Loading Your Program into the EEPROM
  28. Appendix 7—Pulse-Width Modulation
  29. Appendix 8—HC11 Instruction Set
  30. Appendix 9—Comprehensive Glossary

Product information

  • Title: Microcontroller Programming
  • Author(s): Syed R. Rizvi
  • Release date: April 2016
  • Publisher(s): CRC Press
  • ISBN: 9781000755299