You are previewing Microcontrollers, Second Edition.
O'Reilly logo
Microcontrollers, Second Edition

Book Description

This completely updated second edition of MICROCONTROLLERS: FROM ASSEMBLY LANGUAGE TO C USING THE PIC24 FAMILY covers assembly language, C programming, and hardware interfacing for the Microchip PIC24 family, a recently updated microcontroller family from Microchip. Hardware interfacing topics include parallel port usage, analog-to-digital conversion, digital-to-analog conversion, the serial peripheral bus (SPI), the inter-integrated circuit bus (I2C), asynchronous serial communication, and timers. Assembly language programming is covered in the context of the PIC24 instruction set, and no initial knowledge of assembly language programming is assumed. Specific hardware interfacing topics covered are parallel IO, analog-to-digital/digital-to-analog conversion, pulse width modulation, timer usage for IO polling, and industry standard serial interface standards. Interfacing examples include external devices such as pushbutton switches, LEDs, serial EEPROMs, liquid crystal displays (LCDs), keypads, rotary encoders, external digital-to-analog converters, DC motors, servos, temperature sensors, and IR receivers. Master the PIC24 family with MICROCONTROLLERS: FROM ASSEMBLY LANGUAGE TO C USING THE PIC24 FAMILY

Table of Contents

  1. Title Page
  2. Copyright
  3. Dedication
  4. Acknowledgments
  5. About the Authors
  6. Contents
  7. Introduction
    1. Chapter 1 Number System and Digital Logic Review
      1. Learning Objectives
      2. Using Binary Data
      3. Unsigned Number Conversion
      4. Combinational Logic Functions
      5. Combinational Building Blocks
      6. Understanding Sequential Logic
      7. Sequential Building Blocks
      8. Encoding Character Data
      9. Summary
      10. Review Problems
    2. Chapter 2 The Stored Program Machine
      1. Learning Objectives
      2. Problem Solving the Digital Way
      3. Finite State Machine Design
      4. A Stored Program Machine
      5. Modern Computers
      6. Summary
      7. Review Problems
    1. Chapter 3 Introduction to the PIC24 Microcontroller Family
      1. Learning Objectives
      2. Introduction to Microprocessors and Microcontrollers
      3. The PIC24 Microcontroller Family
      4. Data Transfer Instructions and Addressing Modes
      5. File Register Addressing
      6. Basic Arithmetic and Control Instructions
      7. A PIC24 Assembly Language Program
      8. The Clock and Instruction Execution
      9. Summary
      10. Review Problems
    2. Chapter 4 Unsigned 8/16-Bit Arithmetic, Logical, and Conditional Operations
      1. Learning Objectives
      2. Bitwise Logical Operations, Bit Operations
      3. Using the Status Register
      4. Using Shift and Rotate Operations
      5. Using Mixed 8-Bit/16-Bit Operations, Compound Operations
      6. Conditional Execution Using Bit Tests
      7. Unsigned Conditional Tests
      8. Complex Conditional Expressions
      9. Looping
      10. Summary
      11. Review Problems
    3. Chapter 5 Extended Precision and Signed Data Operations
      1. Learning Objectives
      2. Extended Precision Operations
      3. Signed Number Representation
      4. Operations on Signed Data
      5. Branch Instruction Encoding
      6. Summary
      7. Review Problems
    4. Chapter 6 Pointers and Subroutines
      1. Learning Objectives
      2. PIC24 Indirect Addressing Modes
      3. Using Subroutines
      4. The Stack and Call/Return, Push/Pop
      5. Implementing Subroutines in Assembly Language
      6. C Pointers and Arrays
      7. Stack Frames for Function Parameters and Local Variables
      8. Program Space Visibility and Global Variable Initialization
      9. Summary
      10. Review Problems
    5. Chapter 7 Advanced Assembly Language: Higher Math
      1. Learning Objectives
      2. Multiplication
      3. Division
      4. Fixed-Point and Saturating Arithmetic
      5. The dsPIC® Microcontroller Family
      6. Floating-Point Number Representation
      7. BCD Arithmetic
      8. ASCII Data Conversion
      9. Summary
      10. Review Problems
    1. Chapter 8 System Startup and Parallel Port I/O
      1. Learning Objectives
      2. High-Level Languages versus Assembly Language
      3. C Compilation for the PIC24 µC
      4. PIC24 Startup Schematic
      5. ledflash.c—The First C Program for PIC24 Startup
      6. echo.c—Testing the Serial Link
      7. Datasheet Reading—A Critical Skill
      8. Configuration Bits
      9. Clock Generation
      10. Power-On Reset Behavior and Reset Sources
      11. Watchdog Timer, Sleep, Idle, and Doze
      12. The reset.c Test Program
      13. Parallel Port Operation
      14. LED/Switch I/O and State Machine Programming
      15. Interfacing to an LCD Module
      16. The PIC24E versus the PIC24F and PIC24H Families
      17. Summary
      18. Review Problems
    2. Chapter 9 Interrupts and a First Look at Timers
      1. Learning Objectives
      2. Interrupt Basics
      3. PIC24 µC Interrupt Details
      4. ISR Functions in C
      5. Change Notification Interrupts
      6. INTx External Interrupts and Remappable Pins
      7. Periodic Timer Interrupts
      8. Interrupt-Driven LED/Switch I/O
      9. Filtering Noisy Inputs
      10. A Rotary Encoder Interface
      11. A Keypad Interface
      12. On Writing and Debugging ISRs
      13. Summary
      14. Review Problems
    3. Chapter 10 Asynchronous and Synchronous Serial I/O
      1. Learning Objectives
      2. I/O Channel Basics
      3. Synchronous, Asynchronous Serial I/O
      4. The PIC24 UART
      5. Using the PIC24 UART with C
      6. Interrupt-Driven I/O with the PIC24 UART
      7. The RS-232 Standard
      8. The Serial Peripheral Interface (SPI)
      9. SPI Example: The MCP41xxx Digital Potentiometer
      10. SPI Example: PIC24 μC Master to DS1722 Thermometer
      11. SPI Example: PIC24 µC Master to PIC24 μC Slave
      12. The I2C Bus
      13. I2C on the PIC24 μC
      14. I2C Example: PIC24 μC Master to DS1631 Thermometer
      15. I2C Example: PIC24 μC Master to 24LC515 Serial EEPROM
      16. Ping-Pong Buffering for Interrupt-Driven Streaming Data
      17. Summary
      18. Review Problems
    4. Chapter 11 Data Conversion
      1. Learning Objectives
      2. Data Conversion Basics
      3. Analog-to-Digital Conversion
      4. The PIC24 Analog-to-Digital Converter
      5. Digital-to-Analog Conversion
      6. External Digital-to-Analog Converter Examples
      7. Summary
      8. Review Problems
    5. Chapter 12 Timers
      1. Learning Objectives
      2. Pulse Width Measurement
      3. Pulse Width, Period Measurement Using Input Capture
      4. Application: Using Capture Mode for an Infrared Decoder
      5. The Output Compare Module
      6. Pulse Width Modulation
      7. PWM Application: DC Motor Speed Control and Servo Control
      8. A PWM DAC
      9. Time Keeping Using Timer1 and RTCC (PIC 24H/F Families)
      10. Summary
      11. Review Problems
    6. Chapter 13 Advanced Hardware Topics
      1. Learning Objectives
      2. Direct Memory Access
      3. Using the PIC24 μC as an I2C Slave
      4. Bus Arbitration for the I2C Bus
      5. The Controller Area Network (CAN)
      6. The PIC24 ECAN™ Module
      7. Run-Time Self-Programming
      8. Summary
      9. Review Problems
    7. Chapter 14 Operating Systems for Embedded Systems
      1. Learning Objectives
      2. Operating System Concepts
      3. Embedded Systems Operating System for the Microchip PIC24 μC
      4. Design: Adding an ESOS Service for I2C
      5. Summary
      6. Review Problems
    1. Appendix A PIC24 Architecture and Instruction Set Summary
    2. Appendix B Circuits 001
      1. Voltage, Current, and Resistance
      2. Capacitors
    3. Appendix C Problem Solutions
    4. Appendix D References
  12. Index