Main

Lab 0: Introduction to 16-bit 18-pin Starter Board and PIC Development Tools

Starts: NOW!
Demo Due: Week 3 (Sep 06 - Sep 10)
Points: 25

Updates and Clarifications:

Aug 30:: HyperTerminal is not installed by default in Windows Vista or Windows 7. An good alternative to HypetTerminal is TeraTerm available at: http://en.sourceforge.jp/projects/ttssh2/downloads/47683/teraterm-4.66.exe/.

Datasheets and References

Lab Overview:

In this lab, you will familiarize yourself with PIC microcontrollers, the 16-bit 28-pin starter board, the PICKit3 in-circuit debugger, and C-based software development using the MPLAB Integrated Development Environment.

Provided Software Code:

Source Code for Lab 0 Assignment: lab0.c

Lab Procedure and Demo:

  1. Install Microchip MPLAB and MPLAB C Compiler for PIC24 MCUs.
  2. Read the Microchip 16-bit 28-pin Starter Board User's Guide to familiarize yourself with your development board.
  3. Replace the dsPIC33F microcontroller that can pre-installed within the 16-bit 28-pin starter board, with the PIC24F microcontroller provided within the small black antistatic box. Note: In this lab assignment (and all lab assignments throughout this course), we will be using the PIC24F microcontroller.
  4. Follow the tutorial in Chapter 2 of the User's Guide with the following modifications:
    1. The device we are utilizing is the PIC24FJ64GA002. Please sure to select this device in Step 1 of the Project Wizard.
    2. Use the provide software code, lab0.c in place of the demo code provided within your development board.
    3. Do not use a linker script. Specifically, do not add a linker script to your project in Step 4 of the Project Wizard.
    4. Add the device specific header file for the PIC24FJ64GA002 to your project in Step 4 of the Project Wizard. This header file (p24fj64ga002.h) should be located in C:\Program Files\Microchip\MPLAB C30\support\PIC24F\h\ directory.
    5. Before building your code, you must specify a heap size. This can be done using the following steps:
      1. Select Build Options...->Project from the Project menu.
      2. Select the MPLABLINK30 tab.
      3. Enter a size of heap of 512 under Heap Size
    6. Select PICKit3 as the Debugger (or Programmer) in place of the MPLAB ICD2. The setup and configuration for the PICKit3 should follow the same steps as outlined in the tutorial.
    7. You will need to utilize HyperTerminal (or similar program) to communication with the PIC to receive and send characters. Please read the comments within the provided software code to determine the correct serial configuration settings.
    8. Program the PIC for stand-alone operation. In the provided software code, the configuration bits are specified within the software code rather than through MPLAB. In order to program the PIC for stand-alone operation, you will need to modify these configuration bit settings. Please refer to both the comments within the provided software code and the MPLAB documentation to determine the correct settings for programming your PIC for stand-alone operation.
  5. Modify the provided program to support the requirements:
    1. The only LED that should be illuminated is the LED that is blinking. Modify the software code to ensure that only the currently blinking LED is illuminated. Hint: Be careful to make sure you change only change the output (latch) settings for the outputs connected to the LEDs.
    2. SW1 of the 16-bit 28-pin Starter Board is connected to a pin within PORTB of the PIC microcontroller. Determine which pin on the PIC the switch is connected to. Assign the appropriate value to the appropriate TRISB register bit to configure this bit as an input.
    3. Modified the main loop of the software application such that whenever the SW1 is continuously pressed, the currently selected LED will blink twice as fast. When SW1 is released the LEDs will blink at the initially defined rate.
      1. To get the LED to blink twice as fast, you can simply assign one half the value already calculated for the PR1 register in the provided software code. Be sure to reset this value when the button is released.
      2. Whenever you update the PR1 register, the TMR1 register should be reset to 0. Otherwise, you may notice some undesired behavior. Hint: The TMR1 register should be reset when assigning a new new value to the PR1 register.
      3. Extra Credit (1 point): Provide an explanation and demonstration of why not resetting the TMR1 register lead to undesired behavior.

Stand-Alone Program Demo and Code Explanation

During Week 3(Sep 06 - Sep 10), the TAs will be available on the Wednesday, Thursday, and Friday lab sections for you to demonstrate your Lab 0 assignment. During this demo, you will need to both provide a demonstration of your working stand-alone programmed board and provide an explanation of the required modifications made to the provided software code.

Note: As Monday of Week 3 is a holiday (Labor Day), students can attend any lab section to demo their Lab 0 assignment. If you ABSOLUTELY cannot make it to any of the lab sections, please contact the instructor immediately.