Programming 16-Bit PIC Microcontrollers in C

Book description

• A Microchip insider tells all on the newest, most powerful PICs ever!

• FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software

• Includes handy checklists to help readers perform the most common programming and debugging tasks

The new 16-bit PIC24 chip provides embedded programmers with more speed, more memory, and more peripherals than ever before, creating the potential for more powerful cutting-edge PIC designs. This book teaches readers everything they need to know about these chips: how to program them, how to test them, and how to debug them, in order to take full advantage of the capabilities of the new PIC24 microcontroller architecture.

Author Lucio Di Jasio, a PIC expert at Microchip, offers unique insight into this revolutionary technology, guiding the reader step-by-step from 16-bit architecture basics, through even the most sophisticated programming scenarios. This book’s common-sense, practical, hands-on approach begins simply and builds up to more challenging exercises, using proven C programming techniques. Experienced PIC users and newcomers to the field alike will benefit from the text’s many thorough examples, which demonstrate how to nimbly side-step common obstacles, solve real-world design problems efficiently, and optimize code for all the new PIC24 features.

You will learn about:
• basic timing and I/O operations,
• multitasking using the PIC24 interrupts,
• all the new hardware peripherals
• how to control LCD displays,
• generating audio and video signals,
• accessing mass-storage media,
• how to share files on a mass-storage device with a PC,
• experimenting with the Explorer 16 demo board, debugging methods with MPLAB-SIM and ICD2 tools, and more!

·A Microchip insider tells all on the newest, most powerful PICs ever!

·Condenses typical introductory "fluff" focusing instead on examples and exercises that show how to solve common, real-world design problems quickly

·Includes handy checklists to help readers perform the most common programming and debugging tasks

·FREE CD-ROM includes source code in C, the Microchip C30 compiler, and MPLAB SIM software, so that readers gain practical, hands-on programming experience

·Check out the author's Web site at http://www.flyingpic24.com for FREE downloads, FAQs, and updates

Table of contents

  1. Cover
  2. Contents (1/5)
  3. Contents (2/5)
  4. Contents (3/5)
  5. Contents (4/5)
  6. Contents (5/5)
  7. Preface
  8. Introduction
    1. Who should read this book?
    2. Structure of the book
    3. What this book is not
    4. Checklists
  9. PART I (1/5)
  10. PART I (2/5)
  11. PART I (3/5)
  12. PART I (4/5)
  13. PART I (5/5)
    1. CHAPTER 1: THE FIRST FLIGHT (1/5)
    2. CHAPTER 1: THE FIRST FLIGHT (2/5)
    3. CHAPTER 1: THE FIRST FLIGHT (3/5)
    4. CHAPTER 1: THE FIRST FLIGHT (4/5)
    5. CHAPTER 1: THE FIRST FLIGHT (5/5)
      1. Flight plan (1/5)
      2. Flight plan (2/5)
      3. Flight plan (3/5)
      4. Flight plan (4/5)
      5. Flight plan (5/5)
      6. Preflight checklist (1/5)
      7. Preflight checklist (2/5)
      8. Preflight checklist (3/5)
      9. Preflight checklist (4/5)
      10. Preflight checklist (5/5)
      11. The flight (1/5)
      12. The flight (2/5)
      13. The flight (3/5)
      14. The flight (4/5)
      15. The flight (5/5)
        1. Compiling and linking
        2. Building the first project
        3. PORT initialization
        4. Retesting PORTA
        5. Testing PORTB
      16. Post-flight briefing (1/5)
      17. Post-flight briefing (2/5)
      18. Post-flight briefing (3/5)
      19. Post-flight briefing (4/5)
      20. Post-flight briefing (5/5)
      21. Notes for assembly experts
      22. Notes for PIC MCU experts
      23. Notes for C experts
      24. Tips and tricks
      25. Exercises
      26. Books
      27. Links
    6. CHAPTER 2: A LOOP IN THE PATTERN
      1. Flight plan
      2. Preflight checklist
      3. The flight (1/2)
      4. The flight (2/2)
        1. An animated simulation
        2. Using the Logic Analyzer
      5. Post-flight briefing
      6. Notes for assembly experts
      7. Notes for PIC microcontroller experts
      8. Notes for C experts
      9. Tips and tricks
      10. Exercises
      11. Books
      12. Links
    7. CHAPTER 3: MORE PATTERN WORK, MORE LOOPS
      1. Flight plan
      2. Preflight checklist
      3. The flight
        1. Do Loops
        2. Variable declarations
        3. for loops
        4. More loop examples
        5. Arrays
        6. A new demo
        7. Testing with the Logic Analyzer
        8. Using the Explorer16 demonstration board
      4. Post-flight briefing
      5. Notes for assembly experts
      6. Notes for PIC microcontroller experts
      7. Notes for C experts
      8. Tips and tricks
      9. Exercises
      10. Books
      11. Links
    8. CHAPTER 4: NUMB3RS
      1. Flight plan
      2. Preflight checklist
      3. The flight
        1. On optimization (or lack thereof)
        2. Testing
        3. Going long
        4. Note on the multiplication of long integers
        5. Long long multiplication
        6. Floating point
      4. Notes for C experts
        1. Measuring performance
      5. Post-flight briefing
        1. Notes for assembly experts
      6. Notes for PIC microcontroller experts
      7. Tips and tricks
        1. Math libraries
        2. Complex data types
      8. Exercises
      9. Books
      10. Links
    9. CHAPTER 5: INTERRUPTS
      1. Flight plan
      2. Preflight checklist
      3. The flight (1/3)
      4. The flight (2/3)
      5. The flight (3/3)
        1. Nesting of interrupts
        2. Traps
        3. A template and an example for Timer1 interrupt
        4. A real example with Timer1
        5. Testing the Timer1 interrupt
        6. The secondary oscillator
        7. The real-time clock calendar (RTCC)
        8. Managing multiple interrupts
      6. Post-flight briefing
      7. Notes for C experts
      8. Notes for assembly experts
      9. Notes for PIC microcontroller experts
      10. Tips and tricks
      11. Exercises
      12. Books
      13. Links
    10. CHAPTER 6: TAKING A LOOK UNDER THE HOOD
      1. Flight plan
      2. Preflight checklist
        1. The fl ight
        2. Memory space allocation
        3. Program space visibility
        4. Investigating memory allocation
        5. Looking at the MAP
        6. Pointers
        7. The heap
        8. MPLAB C30 Memory Models
      3. Post-flight briefing
      4. Notes for C experts
      5. Notes for assembly experts
      6. Notes for PIC microcontroller experts
      7. Tips and tricks
      8. Exercises
      9. Books
      10. Links
  14. PART II FLYING SOLOŽ
    1. CHAPTER 7: COMMUNICATION
      1. Flight plan
      2. Preflight checklist
      3. The flight
        1. Synchronous serial interfaces
        2. Asynchronous serial interfaces
      4. Parallel interfaces (1/3)
      5. Parallel interfaces (2/3)
      6. Parallel interfaces (3/3)
        1. Synchronous communication using the SPI modules
        2. Testing the Read Status Register command
        3. Writing to the EEPROM
        4. Reading the memory contents
        5. A nonvolatile storage library
        6. Testing the new NVM library
      7. Post-flight briefing
      8. Notes for C experts
      9. Notes for the experts
      10. Notes for PIC microcontroller experts
      11. Tips and tricks
      12. Exercises
      13. Books
      14. Links
    2. CHAPTER 8: ASYNCHRONOUS COMMUNICATION
      1. Flight plan
      2. Preflight checklist
      3. The flight
      4. UART confi guration (1/3)
      5. UART confi guration (2/3)
      6. UART confi guration (3/3)
        1. Sending and receiving data
        2. Testing the serial communication routines
        3. Building a simple console library
        4. Testing a VT100 terminal
        5. Using the serial port as a debugging tool
        6. The matrix
      7. Post-flight briefing
      8. Notes for C experts
      9. Notes for PIC microcontroller experts
      10. Tips and tricks
      11. About the ICD2 and UARTs on ICE
      12. Exercises
      13. Books
      14. Links
    3. CHAPTER 9: GLASS BLISS
      1. Flight plan
      2. Pre-flight checklist
      3. The flight
        1. HD44780 controller compatibility
        2. The Parallel Master Port
        3. Configuring the PMP for LCD module control
        4. A small library of functions to access an LCD display
        5. Advanced LCD control
      4. Post-flight briefing
      5. Notes for C experts
      6. Tips and tricks
      7. Exercises
      8. Books
      9. Links
    4. CHAPTER 10: IT’S AN ANALOG WORLD
      1. Flight plan
      2. Preflight checklist
      3. The flight
        1. The fi rst conversion
        2. Automatic sampling timing
        3. Developing a demo
        4. Developing a game
        5. Measuring temperature
        6. The breath-alizer game
      4. Post-flight briefing
      5. Notes for C experts
      6. Tips and tricks
      7. Exercises
      8. Books
      9. Links
  15. PART III – CROSS-COUNTRY FLYING
    1. CHAPTER 11: CAPTURING INPUTS
    2. CHAPTER 12: THE DARK SCREEN
      1. Flight plan
      2. The flight (1/12)
      3. The flight (2/12)
      4. The flight (3/12)
      5. The flight (4/12)
      6. The flight (5/12)
      7. The flight (6/12)
      8. The flight (7/12)
      9. The flight (8/12)
      10. The flight (9/12)
      11. The flight (10/12)
      12. The flight (11/12)
      13. The flight (12/12)
        1. Generating the composite video signal
        2. Using the Output Compare modules
        3. Memory allocation
        4. Image serialization
        5. Building the video module
        6. Testing the video generator
        7. Measuring performance
        8. The dark screen
        9. A test pattern
        10. Plotting
        11. A starry night
        12. Line drawing
        13. Bresenham algorithm
        14. Plotting math functions
        15. Two-dimensional function visualization
        16. Fractals
        17. Text
        18. Testing the TextOnGPage module
        19. Developing a text page video
        20. Testing the text page performance
      14. Post-flight briefing
      15. Tips and tricks
      16. Exercises
      17. Books
      18. Links
    3. CHAPTER 13: MASS STORAGE
      1. Flight plan
      2. The flight (1/4)
      3. The flight (2/4)
      4. The flight (3/4)
      5. The flight (4/4)
        1. The SD/MMC card physical interface
        2. Interfacing to the Explorer16 board
        3. Starting a new project
        4. Selecting the SPI mode of operation
        5. Sending commands in SPI mode
        6. Completing the SD/MMC card initialization
        7. Reading data from an SD/MMC card
        8. Writing data to an SD/MMC card
        9. Using the SD/MMC interface module
      6. Post-flight briefing
      7. Tips and tricks
      8. Exercises
      9. Books
      10. Links
    4. CHAPTER 14: FILE I/O
      1. Flight plan
      2. The flight (1/9)
      3. The flight (2/9)
      4. The flight (3/9)
      5. The flight (4/9)
      6. The flight (5/9)
      7. The flight (6/9)
      8. The flight (7/9)
      9. The flight (8/9)
      10. The flight (9/9)
        1. Sectors and Clusters
        2. The File Allocation Table (FAT)
        3. The Root Directory
        4. The treasure hunt
        5. Opening a fi le
        6. Reading data from a file
        7. Closing a file
        8. Creating the fileio module
        9. Testing fopenM() and freadM()
        10. Writing data to a file
        11. Closing a file, second take
        12. Accessory functions
        13. Testing the complete fileio module
        14. Code Size
      11. Post-flight briefing
      12. Tips and tricks
      13. Exercises
      14. Books
      15. Links
    5. CHAPTER 15: VOLARE
      1. Flight plan
      2. The flight (1/8)
      3. The flight (2/8)
      4. The flight (3/8)
      5. The flight (4/8)
      6. The flight (5/8)
      7. The flight (6/8)
      8. The flight (7/8)
      9. The flight (8/8)
        1. The PS/2 communication protocol
        2. Interfacing a PIC24 to the PS/2
        3. Input Capture
        4. Testing the Input Capture method using Stimulus Scripts
        5. Testing the PS/2 receive routines
        6. The simulation
        7. The Simulator Profile
        8. Another method – Change Notification
        9. Evaluating cost
        10. A third method – I/O polling
        11. Testing the I/O polling method
        12. Cost and efficiency of the solution
        13. Completing the interface: adding a FIFO buffer
        14. Completing the interface: performing key codes decoding
      10. Post-flight briefing (1/8)
      11. Post-flight briefing (2/8)
      12. Post-flight briefing (3/8)
      13. Post-flight briefing (4/8)
      14. Post-flight briefing (5/8)
      15. Post-flight briefing (6/8)
      16. Post-flight briefing (7/8)
      17. Post-flight briefing (8/8)
      18. Tips and tricks (1/8)
      19. Tips and tricks (2/8)
      20. Tips and tricks (3/8)
      21. Tips and tricks (4/8)
      22. Tips and tricks (5/8)
      23. Tips and tricks (6/8)
      24. Tips and tricks (7/8)
      25. Tips and tricks (8/8)
        1. Stalling transmissions from the keyboard – Open-Drain Output Control
      26. Exercises (1/8)
      27. Exercises (2/8)
      28. Exercises (3/8)
      29. Exercises (4/8)
      30. Exercises (5/8)
      31. Exercises (6/8)
      32. Exercises (7/8)
      33. Exercises (8/8)
      34. Books (1/8)
      35. Books (2/8)
      36. Books (3/8)
      37. Books (4/8)
      38. Books (5/8)
      39. Books (6/8)
      40. Books (7/8)
      41. Books (8/8)
      42. Links (1/8)
      43. Links (2/8)
      44. Links (3/8)
      45. Links (4/8)
      46. Links (5/8)
      47. Links (6/8)
      48. Links (7/8)
      49. Links (8/8)
      50. Flight plan
      51. The flight
      52. Using the PIC24 OC modules in PWM mode
      53. Testing the PWM as a D/A converter
      54. Producing analog waveforms
      55. Reproducing voice messages
      56. A media player
      57. The WAVE file format
      58. The play() function (1/2)
      59. The play() function (2/2)
      60. The low level audio routines
      61. Testing the WAVE file player
      62. Optimizing the fi le I/O
      63. LED Profi ling
      64. Looking under the hood for more
  16. Post-flight briefing
  17. Tips and tricks
  18. Exercises
  19. Books
  20. Links
  21. About the Author
  22. Index (1/3)
  23. Index (2/3)
  24. Index (3/3)

Product information

  • Title: Programming 16-Bit PIC Microcontrollers in C
  • Author(s): Lucio Di Jasio
  • Release date: March 2007
  • Publisher(s): Newnes
  • ISBN: 9780080475462