Microchip Technology dsPICDEM 1.1 Plus Development Board User guide

dsPICDEM™ 1.1 Plus
Development Board
User’s Guide
© 2006 Microchip Technology Inc. DS70099D
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchip’s Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as “unbreakable.”
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchip’s code protection feature may be a violation of the Digit al Millennium Copyright Act. If suc h a c t s allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Information contained in this publication regarding device applications and t he lik e is provided only for your convenience and may be su perseded by upda t es . It is y our responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life supp ort and/or safety ap plications is entir ely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless M icrochip from any and all dama ges, claims, suits, or expenses re sulting from such use. No licens es are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.
Trademarks
The Microchip name and logo, the Microchip logo, Accuron, dsPIC, K
EELOQ, microID, MPLAB, PIC, PICmicro, PICSTART,
PRO MATE, PowerSmart, rfPIC and SmartShunt are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries.
AmpLab, FilterLab, Migratable Memory, MXDEV, MXLAB, SEEVAL, SmartSensor and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, ECAN, ECONOMONITOR, FanSense, FlexROM, fuzzyLAB, In-Circuit Serial Programming, ICSP, ICEPIC, Linear Active Thermistor, Mindi, MiWi, MPASM, MPLIB, MPLINK, PICkit, PICDEM, PICDEM.net, PICLAB, PICtail, PowerCal, PowerInfo, PowerMate, PowerTool, REAL ICE, rfLAB, rfPICDEM, Select Mode, Smart Serial, SmartT el, Total Endurance, UNI/O, WiperLock and ZENA are trademarks of Microchip Technology I ncorporat ed in the U.S.A. and other countries.
SQTP is a service mark of Microchip Technology Incorporated in the U.S.A.
All other trademarks mentioned herein are property of their respective companies.
© 2006, Microchip Technology Incorporated, Pr inted in the U.S.A., All Rights Reserved.
Printed on recycled paper.
Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona, Gresham, Oregon and Mountain View, California. The Company’s quality system processes and procedures are for its
®
8-bit MCUs, KEELOQ
PIC microperipherals, nonvolatile memory and analog products. In addition, Microchip’s quality system for the design and manufacture of development systems is ISO 9001:2000 certified.
®
code hopping devices, Serial EEPROMs,
DS70099D-page ii © 2006 Microchip Technology Inc.
dsPICDEM™ 1.1 PLUS
DEVELOPMENT BOARD
USER’S GUIDE

Table of Contents

Preface ........................................................................................................................... 1
Chapter 1. Introduction
1.1 Introduction .....................................................................................................9
1.2 Highlight s ......... ............. .. .. ........................... .. .. ........................... .. .. ................ 9
1.3 dsPICDEM™ 1.1 Plus DEVELOPMENT BOARD Kit ....................................9
1.4 dsPICDEM™ 1.1 Plus Development Board Features ..................................10
1.5 Supported Plug-In Modules ..........................................................................11
1.6 Running the dsPICDEM™ 1.1 Plus Demonstration Program ......................12
Chapter 2. Using dsPIC30F Devices
2.1 Introduction ...................................................................................................13
2.2 Highlight s ......... ............. .. .. ........................... .. .. ........................... .. .. .............. 13
2.3 Tutori al Ove rview .................. .. .. ........................... .. .. .................................... 13
2.4 Creating the Pro j e c t .......................................................................... ... .. ....... 14
2.5 Building the Code .........................................................................................19
2.6 Programming the Chip ................................................................................. 21
2.7 Debugging the Code ....................................................................................25
Chapter 3. dsPIC30F Demonstration Program Operation
3.1 Introduction ...................................................................................................29
3.2 Highlight s ......... ............. .. .. ........................... .. .. ........................... .. .. .............. 29
3.3 Demonstra tion Program Op e ra tion .... .. ........................................................ 2 9
3.4 Data and Control Flow ..................................................................................36
3.5 dsPIC30F Demonstration Performance Metrics ...........................................39
3.6 Board Self-Test Code Module Summary ...................... ...................... .. ........42
Chapter 4. Using dsPIC33F and PIC24H/24F Devices
4.1 Introduction ...................................................................................................43
4.2 Highlight s ......... ............. .. .. ........................... .. .. ........................... .. .. .............. 43
4.3 Tutorial Ov e r view ..... .. .......................... .. ........................... .. .. .............. .. ....... 43
4.4 Creating the Pro j e c t .......................................................................... ... .. ....... 44
4.5 Building the Code .........................................................................................49
4.6 Programming the Chip ................................................................................. 51
4.7 Debugging the Code ....................................................................................55
4.8 Additional Code Examples ................................................................... .. ......59
Chapter 5. dsPICDEM™ 1.1 Developmen t Ha rdwa re
5.1 dsPICDEM™ 1.1 Plus Development Board Hardware Overview .................61
© 2006 Microchip Technology Inc. DS70099D-page iii
dsPICDEM™ 1.1 Plus Development Board User’s Guide
Appendix A. Hardware Drawings and Schematics
A.1 Introduction ..................................................................................................67
A.2 Highlight s ................ .......................... ... .. .......................... ... .. ....................... 67
Appendix B. LCD Controller Specification
B.1 Overview .......... ........................................ .. .. ........................... .. .. ................. 75
B.2 LCD Controller Interface .............................................................................. 75
B.3 Commands ................................................................................................... 76
B.4 General Commands .....................................................................................78
B.5 Character commands ................................................................................... 79
B.6 Pixel comm a n ds ............................................................................... .. .. ........ 81
B.7 Column com mands ................ ..................................................... ... .. ............ 8 2
B.8 Example s ................ ........................................ .. ........................................ .. . 83
Index .............................................................................................................................85
Worldwide Sales and Service .....................................................................................88
DS70099D-page iv © 2006 Microchip Technology Inc.
dsPICDEM™ 1.1 PLUS
DEVELOPMENT BOARD

Preface

NOTICE TO CUSTOMERS
All documentation becomes dated, and this manual is no exception. Microchip tools and documentation are constantly evolving to meet customer needs, so some actual dialogs and/or tool descriptions may differ from those in this document. Please refer to our web site (www.microchip.com) to obtain the latest documentation available.
Documents are identified with a “DS” number. This number is located on the bottom of each page, in front of the page number. The numbering convention for the DS number is “DSXXXXXA”, where “XXXXX” is the document number and “A” is the revision level of the document.
For the most up-to-date information on development tools, see the MPLAB Select the Help menu, and then Topics to open a list of available on-line help files.
®
IDE on-line help.
INTRODUCTION
This chapter contains general information that will be useful to know before using the dsPICDEM™ 1.1 Plus Development Board. Items discussed in this chapter include:
• About This Guide
• Conventions Used in this Guide
• Warranty Registration
• Recommended Reading
• The Microchip Web Site
• Development Systems Customer Change Notification Service
• Customer Support
• Document Revision History
ABOUT THIS GUIDE
This document describes how to use the dsPICDEM™ 1.1 Plus Development Board as a development tool to emulate and debug firmware on a target board. The manual layout is as follows:
Chapter 1: Introduction – This chapter introduces the dsPICDEM™ 1.1 Plus Development Board and provides a brief description of the hardware.
Chapter 2: Using dsPIC30F Devices – This chapter goes through a basic step-by-step process for getting your dsPICDEM™ 1.1 Plus Development Board up and running with the MPLAB devices.
Chapter 3: Demonstration Program Operation – This chapter presents a detailed description of the operational functionality of the sample code, which is preprogrammed into the dsPIC30F device.
®
In-Circuit Debugger 2 (ICD 2) using dsPIC30F
© 2006 Microchip Technology Inc. DS70099D-page 1
dsPICDEM™ 1.1 Plus Development Board User’s Guide
Chapter 4. Using dsPIC33F/PIC24H Devices – This chapter goes through a basic step-by-step process for getting your dsPICDEM™ 1.1 Plus Development Board up and running with the MPLAB
Chapter 5: dsPICDEM™ 1.1 Plus Development Board Hardware – This chap­ter presents the features of the dsPICDEM™ 1.1 Plus Development Board in more detail.
Appendix A: Hardware Drawings and Schematics – This Appendix illustrates the dsPICDEM™ 1.1 Plus Development Board layout and hardware schematic diagrams.
Appendix B: LCD Controller Specification – This section pr esent s the 1 22 x 32 Graphics LCD Controller Interface Specifications.
Index – This section provides cross-reference listing of terms, features and sections of this document.
Worldwide Sales and Service – A listing of Microchip sales and service locations and telephone numbers worldwide.
®
ICD 2 using dsPIC30F devices.
DS70099D-page 2 © 2006 Microchip Technology Inc.
CONVENTIONS USED IN THIS GUIDE
This manual uses the following docum entat io n conven tion s:
DOCUMENTATION CONVENTIONS
Description Represents Examples
Arial font:
Italic characters Referenced books MPLAB
Initial caps A window the Output window
Quotes A field name in a window or
Underlined, italic text with right angle bracket
Bold characters A dialog button Click OK
N‘Rnnnn A number in verilog format,
Text in angle brackets < > A key on the keyboard Press <Enter>, <F1>
Courier New font:
Plain Courier New Sam ple source code #define START
Italic Courier New A variable argument file.o, where file can be
Square brackets [ ] Optional arguments mcc18 [options] file
Curly brackets and pipe character: { | }
Ellipses... Replaces r epeated text var_name [,
Preface
®
IDE User’s Guide
Emphasized text ...is the only comp ile r...
A dialog the Settings dialog A menu selection select Enable Programmer
“Save project before build”
dialog A menu path File>Save
A tab Click the Power tab
4‘b0010, 2‘hF1 where N is the tota l number of digits, R is th e radi x and n is a digit.
Filenames autoexec.bat File paths c:\mcc18\h Keywords _asm, _endasm, static Command-line options -Opa+, -Opa- Bit values 0, 1 Constants 0xFF, ‘A’
any valid filename
[options]
Choice of mutually exclusive arguments; an OR selection
Represents code supplied by user
errorlevel {0|1}
var_name...]
void main (void)
{ ...
}
© 2006 Microchip Technology Inc. DS 70099D-page 3
dsPICDEM™ 1.1 Plus Development Board User’s Guide
WARRANTY REGISTRATION
Please complete the enclosed Warranty Registration Card and mail it promptly. Sending in the Warranty Registration Card entitles users to receive new product updates. Interim software releases are available at the Microchip web site.
RECOMMENDED READING
This user’s guide describes how to use the dsPICDEM™ 1.1 Plus Development Board. Other useful documents are listed below:
dsPIC30F Family Reference Manual (DS70 046)
Consult this document for detailed information on the dsPIC30F device operation. The manual explains the operation of the dsPIC30F MCU family architecture and peripheral modules but does not cover the specifics of each device. Refer to the appropriate device data sheet, mentioned below, for device-specific information.
dsPIC30F/33F Programmer’s Reference Manual (DS70157)
This manual is a software developer’s reference for the dsPIC30F/33F 16-bit MCU device families. This manual describes the instruction set in detail and also provides general information to assist the user in developing software for the dsPIC30F MCU family.
dsPIC30F Family Overview (DS70043)
This document provides an overview of the features and functionality of the dsPIC DSC product family. It helps determine how the dsPIC 16-bit Digital Signal Controller Family fits a specific product application. For detailed information about any of the functionality, refer to the “dsPIC30F Family Reference Manual” (DS70 046 ).
PIC24H Family Data Sheet (DS70175)
This data sheet summarizes the features of the PIC24H family of devices. It provides essential information needed to develop software for these devices.
dsPIC33F Family Data Sheet (DS70165)
This data sheet summarizes the features of the dsPIC33F family of devices. It provides essential information needed to develop software for these devices.
MPLAB
This document details Microchip Technology’s language tools for dsPIC DSC devices based on GNU technology. The language tools discussed are:
• MPLAB ASM30 Assembler
• MPLAB LINK30 Linker
• MPLAB LIB30 Archiver/Librarian
• Other Utilities
MPLAB
The purpose of this document is to help you use Microchip’s MPLAB C30 C compiler for dsPIC guage tool, based on source code from the Free Software Foundation (FSF). For more information about the FSF, see www.fsf.org.
Other GNU language tools available from Microchip are:
• MPLAB ASM30 Assembler
• MPLAB LINK30 Linker
• MPLAB LIB30 Librarian/Archiver
®
ASM30, MPLAB® LINK30 and Utilities User’s Guide (DS51317)
®
C30 C Compiler User’s Guide (DS51284)
®
DSC devices to develop your application. MPLAB C30 is a GNU-based lan-
®
DS70099D-page 4 © 2006 Microchip Technology Inc.
Preface
MPLAB IDE Simulator, Editor User’s Guide (DS51025)
Consult this document for more information pertaining to the installation and features of the MPLAB Integrated Development Environment (IDE) Software.
To obtain any of these documents, contact the nearest Microchip sales location (see back page) or visit the Microchip web site at: www.microchip.com.
© 2006 Microchip Technology Inc. DS 70099D-page 5
dsPICDEM™ 1.1 Plus Development Board User’s Guide
THE MICROCH IP WEB SITE
Microchip provides online support via our web site at www.microchip.com. This web site is used as a means to make files and information easily available to customers. Accessible by using your favorite Internet browser, the web site contains the following information:
Product Support – Data sheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip consultant program member listin g
Business of Microchip – Product selector and ordering guides, latest Microchip press releases, listing of seminars and events, listings of Microchip sales offices, distributors and factory representatives
DEVELOPMENT SYSTEMS CUSTOMER CHANGE NOTIFICATION SERVICE
Microchip’s customer notification service helps keep customers current on Microchip products. Subscribers will receive e-mail notification whenever there are changes, updates, revisions or errata related to a specified product family or development tool of interest.
To register, access the Microchip web site at www.microchip.com, click on Customer Change Notification and follow the registration instructions.
The Development Systems product group categories are:
Compilers – The latest information on Microchip C compilers and other language tools. These include the MPLAB C18 and MPLAB C30 C compilers; MPASM™ and MPLAB ASM30 assemblers; MPLINK™ and MPLAB LINK30 object linkers; and MPLIB™ and MPLAB LIB30 object librarians.
Emulators – The latest information on Microchip in-circuit emulators.This includes the MPLAB ICE 2000 and MPLAB ICE 4000.
In-Circuit Debuggers – The latest information on the Microchip in-circuit debugger, MPLAB ICD 2.
MPLAB Integrated Development Environment for development systems tools. This list is focused on the MPLAB IDE, MPLAB SIM simulator, MPLAB IDE Project Manager and general editing and debugging features.
Programmers – The latest information on Microchip programmers. These include the MPLAB PM3 and PRO MATE Plus and PICkit
®
IDE – The latest information on Microchip MPLAB IDE, the Windows®
®
1 development programmers.
II device programmers and the PICSTART®
DS70099D-page 6 © 2006 Microchip Technology Inc.
CUSTOMER SUPPORT
Users of Microchip products can receive assistance through several channels:
• Distributor or Representative
• Local Sales Office
• Field Application Engineer (FAE)
• Technical Support Customers should contact their distributor, representative or field application engineer
(FAE) for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in the back of this document.
Technical support is available through the web site at: http://support.microchip.com
DOCUMENT REVISION HISTORY
Revision D (October 2006)
This revision reflects an upgrade to the dsPICDEM™ 1.1 Plus Development Board to allow it to accommodate dsPIC30F, dsPIC33F, PIC24H and PIC24F devices.
• Changed board name to dsPICDEM™ 1.1 Plus Development Board.
• Modified power supply circuits to accommodate both 3.3 V and 5V devices.
• Added tutorial and code examples for using the dsPICDEM™ 1.1 Plus Develop­ment Board with dsPIC33F and PIC24H/F devices (see Chapter 4. “Using
dsPIC33F and PIC24H/24F Devices”).
Preface
Revision C (September 2005)
• Last Release of this Document.
• Previous releases contained Advance Information that was updated in Revision C.
© 2006 Microchip Technology Inc. DS 70099D-page 7
dsPICDEM™ 1.1 Plus Development Board User’s Guide
NOTES:
DS70099D-page 8 © 2006 Microchip Technology Inc.
dsPICDEM™ 1.1 PLUS
1
DEVELOPMENT BOARD

Chapter 1. Introduction

1.1 INTRODUCTION

The dsPICDEM™ 1.1 Plus Development Board Kit serves as a development and eval­uation tool for dsPIC30F/33F High Performance Digital Signal Controllers and PIC24H/24F PIC

1.2 HIGHLIGHTS

This chapter discusses:
• dsPICDEM™ 1.1 Plus Development Board Kit
• dsPICDEM™ 1.1 Plus Development Board Features
• Supported Plug-In Modules
• Running the

1.3 dsPICDEM™ 1.1 PLUS DEVELOPMENT BOA RD KIT

®
microcontrollers.
dsPICDEM™ 1.1 Demonstration Program
USER’S GUIDE
The dsPICDEM™ 1.1 Plus Development Board Kit contains the following items:
• The dsPICDEM™ 1.1 Plus Printed Circuit Board (Figure 1-1)
• Preprogrammed dsPIC30F6014A Plug-in Module (Figure 1-2)
• 9V DC Power Supply
• RS-232 Interface Cable
• dsPICDEM™ 1.1 Plus Development Board Kit CD containing demonstration programs

FIGURE 1-1: dsPICDEM™ 1.1 PLUS DEVELOPMENT BOARD

5
2
7
10
26
9
8 7
8
6
27
25
13
4 3
3
11
10
5
14
1
12
4
18
1
16
© 2006 Microchip Technology Inc. DS70099D-page 9
dsPICDEM™ 1.1 Plus Development Board User’s Guide

FIGURE 1-2: dsPIC30F6014A PLUG-IN MODULE

1.4 dsPICDEM™ 1.1 PLUS DEVEL OPMENT BOARD FEATURES

The dsPICDEM™ 1.1 Plus Development Board supports the following features:
Development Board Power
• Separate on-board +5V and +3.3V regulators for VDD and AVDD with direct input from 9V, AC/DC wall adapter
• 9V DC power source input jack for development board
• LED power-on indicator
MPLAB ICD 2 and MPLAB ICE 4000 Connections
• MPLAB ICD 2 programming connector
• Jumper J8 for selection of processor interfaced to the MPLAB ICD 2 Debugger/Programmer
• Emulation header for connection to MPLAB ICE 4000 Emulator
• Pad location for 80-pin TQFP dsPIC DSC device
Serial Communication Channels
• Two RS-232 communication channels
• 6-pin terminal block and configuration jumper for RS-485 and RS-422 communication on UART1 from the dsPIC DSC device
• Single CAN communication channel
DS70099D-page 10 © 2006 Microchip Technology Inc.
Introduction
Voice Band Codec
• Si3000 Voice band Codec chip (U7)
• Jumper J9 for selection of Si3000 Codec mode (Master/Slave)
• Socket U6, optional clock oscillator for Si3000 Voice band Codec
• 4-pin header for the Codec Line In and Line Out
• One 3.5 mm phono jack for the Codec left and right speaker outputs
• One 3.5 mm phono jack for the Codec MIC input
• Codec reset push button switch
Analog
• Three 5 kΩ Potentiometers (RP1-RP3)
• Microchip TC1047A Thermal Sensor (U9)
• MCP41010 Digital Potentiometer (U8)
• MCP602 Operational Amplifiers configured as low-pass filters for temperature sensor and digital potentiometer (U10)
Device Clocking
• 7.3728 MHz crystal (X3) for dsPIC DSC device
• Socket U5, clock oscillator for dsPIC DSC device (alternate clock source, X3 removed)
• Pad for 32.768 kHz crystal (X2) and load caps
Miscellaneous
• Reset push button switch and jumper (J10) for resetting the PIC18F242 LCD controller or the dsPIC DSC device
• Four red LEDs (LED1-LED4)
• Four push button switches (SW1-SW4) for external input stimulus
• 122 x 32 dot addressable LCD
• PIC18F242 LCD controller
• 2 x 50 prototyping header for user hardware expansion (header not installed)
• Prototype area for user hardware

1.5 SUPPORTED PLUG-IN MODULES

The dsPICDEM™ 1.1 Plus Development Board supports these Plug-In Modules:
• dsPIC30F6014A 80L Plug-In Module (MA300014)
• dsPIC33FJ256GP710 100-to-80L Plug-In Module (MA330012)
© 2006 Microchip Technology Inc. DS70099D-page 11
dsPICDEM™ 1.1 Plus Development Board User’s Guide

1.6 RUNNING THE dsPICDEM™ 1.1 PLUS DEMONSTRATION PROGRAM

The dsPICDEM™ 1.1 Plus Development Board is supplied with a pre-loaded demon­stration program that exercises principal CPU functions and peripheral options that interact with typical user application programs.
When you apply power to the dsPICDEM™ 1.1 Plus Development Board, the LCD menu displays these demonstration functions:
• Data Acquisition Display
• Digital Signal Processing (DSP) Operations
• Dual Tone Multi-Frequency (DTMF) Generation Switches SW2-SW4 select one of these three choices. Each choice offers a submenu,
which provides for additional options using switches SW1-SW4. Refer to Chapter 3. “dsPIC30F Demonstration Program Operation” for full details
on the demonstration code operation .
DS70099D-page 12 © 2006 Microchip Technology Inc.

Chapter 2. Using dsPIC30F Devices

2.1 INTRODUCTION

This chapter is a self-paced tutorial to get you started using the dsPICDEM™ 1.1 Plus Development Board with dsPIC30F devices. The tutorial demonstrates the main fea­tures of MPLAB IDE Integrated Development Environment and the MPLAB ICD 2 In-Circuit Debugger as they are used with the dsPICDEM™ 1.1 Plus Development Board. Upon completing this tutorial, you should be able to:
• Create a project using the Project Wizard.
• Assemble and link the code and set the Configuration bits.
• Set up MPLAB IDE to use the MPLAB ICD 2 In-Circuit Debugger.
• Program the chip with the MPLAB ICD 2.
• View the code execution in program memory and source code.
• View registers in a Watch window.
• Set a breakpoint and make the code halt at a chosen location.
• Use the function keys to Reset, Run, Halt and Single Step the code.
dsPICDEM™ 1.1 PLUS
DEVELOPMENT BOARD
USER’S GUIDE

2.2 HIGHLIGHTS

Items discussed in this chapter include:
• Tutorial Overview
• Creating the Project
• Building the Code
• Programming the Chip
• Debugging the Code

2.3 TUTORIAL OVERVIEW

The tutorial program in Tut6014a.s (included with the CD-ROM) is written in assembly code. This program displays text on the LCD and flashes an LED. The source file is used with a linker script file (p30f6014a.gld) and an include file (p30f6014a.inc) to form a comple te proje ct. The tutoria l is a si mple pr oject th at uses a single source code file. More complex projects might use multiple assembler and compiler source files as well as library files and precompiled object files. For simplicity , this tutorial uses only one source file.
There are four steps to this tutorial:
1. Create a project in MPLAB IDE.
2. Assemble and link the code.
3. Program the chip with the MPLAB ICD 2.
4. Debug the code with the MPLAB ICD 2.
© 2006 Microchip Technology Inc. DS70099D-page 13
dsPICDEM™ 1.1 Plus Development Board User’s Guide

2.4 CREATING THE PROJECT

The first step is to create a project and a workspace in MPLAB IDE. Usually, you will have one project in one workspace.
Note: These instructions presume the use of MPLAB 7.20 or newer.
A project contains the files needed to build an application (source code, linker script files, etc.) along with their associations to various build tools and build options.
A workspace contains one or more projects and information on the selected device, debug tool and/or programmer, open windows and their location and other IDE configuration settings.
MPLAB IDE contains a Project Wizard to help create new projects. Before starting, create a folder for the project files for this tutorial (C:\Tutorial is assumed in the instructions that follow). From the dsPICDEM 1_1 Plus Development Board code\Tutorial Code folder on the dsPICDEM™ 1.1 Plus Development Kit CD, copy the Tut6014a.s file into the C:\Tutorial fold er.
Note: All files copied from the CD are read only. If the file needs to be edited, the
attributes will need to be changed.

2.4.1 Select a Device

1. Start MPLAB IDE.
2. Close any workspace that might be open (File>Close Workspace
3. From the Project
4. From the Welcome screen, click Next> to display the Project Wizard Step One dialog (see Figure 2-1).
FIGURE 2-1: PROJECT WIZARD, STEP 1, SELECT A DEVICE
menu, select Project Wizard.
).
DS70099D-page 14 © 2006 Microchip Technology Inc.
Using dsPIC30F Devices
5. From the Device: pull-down list, select dsPIC30F6014A and click Next>. The
Project Wizard Step Two dialog displays (see Figure 2-2).
FIGURE 2-2: PROJECT WIZARD, STEP 2, SELECT LANGUAGE
TOOLSUITE

2.4.2 Select Language Toolsuite

1. From the Active Toolsuite: pull-down menu, select Microchip C30 Toolsuite.
This toolsuite includes the assembler and linker that will be used (the C Compiler is not used).
Note: Steps 2-4 are optional.
2. In the Toolsuite Contents block, select MPLAB ASM30 Assembler
(pic30-as.exe).
3. In the Location block, click Browse... and navigate to:
C:\Program Files\Microchip\MPLAB ASM30 Suite \bin\pic30-as.exe
4. With MPLAB LINK 30 Object Linker (pic30-Id.exe) selected in Toolsuite
Contents, click Browse... and navigate to:
C:\Program Files\Microchip\MPLAB ASM30 Suite \bin\pic30-id.exe
5. Click Next> to continue. The Project Wizard Step Three dialog displays
(see Figure 2-3).
Note: The tool locations for your environment may be different from those shown
in this tutorial.
© 2006 Microchip Technology Inc. DS70099D-page 15
dsPICDEM™ 1.1 Plus Development Board User’s Guide
FIGURE 2-3: PROJECT WIZARD, STEP 3, NAME YOUR PROJECT

2.4.3 Name Your Project

1. In the Project Name text box, type MyProject.
2. Click Browse... and navigate to C:\Tutorial to place your project in the Tutorial folder.
3. Click Next> to continue. The Project Wizard Step Four dialog displays (see Figure 2-4).
DS70099D-page 16 © 2006 Microchip Technology Inc.
Using dsPIC30F Devices
FIGURE 2-4: PROJECT WIZARD, STEP 4, ADD FILES TO PROJECT

2.4.4 Add Files to Project

1. Locate the C:\Tutorial folder and select the Tut6014A.s file.
2. Click Add>> to include the file in the project.
3. Expand the C:\Program Files\Microchip\MPLAB ASM30 Suite\Sup-
port\gld folder and select the p30f6014A.gld file.
4. Click Add>> to include the file in the project. The project now has two files.
5. Click Next> to continue.
6. When the summary screen displays, click Finish. After the project wizard completes, the MPLAB IDE project window shows the
Tut6014A.s file in the Source Files folder and the p30f6014A.gld file in the Linker Scripts folder (see Figure 2-5).
FIGURE 2-5: MPLAB
®
IDE PROJECT WINDOW
© 2006 Microchip Technology Inc. DS70099D-page 17
dsPICDEM™ 1.1 Plus Development Board User’s Guide
A project and workspace has now been created in MPLAB IDE. MyProject.mcw is the workspace file and MyProject.mcp is the project file. Double click the Tut6014A.s file in the project window to open the file. MPLAB IDE should now look similar to Fi gu r e 2-6.
FIGURE 2-6: MPLAB
®
IDE WORKSPACE WINDOWS
DS70099D-page 18 © 2006 Microchip Technology Inc.

2.5 BUILDING THE CODE

In this project, building the code consists of assembling the Tut6014A.s file to create an object file, Tut6014A.o, and then linking the object file to create the Tut6014A.hex and Tut6014A.cof output files. The .hex file contains the data nec­essary to program the device and the .cof file contains additional information that lets you debug at the source code level.
Before building, there are settings required to tell MPLAB IDE where to find the include files and to reserve space for the extra debug code when the MPLAB ICD 2 is used.
The following line is near the top of the Tut6014A.s file:
.include "p30f6014A.inc"
This line causes a standard include file to be used. Microchip provides these files with all the Special Function Register (SFR) labels already defined for convenience.
To build the code, select Build Option s>Project Options dialog displays, as shown in Figure 2-7.

FIGURE 2-7: BUILD OPTIONS

Using dsPIC30F Devices
from the Project> menu. The Build
Browse to the location of the assembler Include folder.
© 2006 Microchip Technology Inc. DS70099D-page 19
dsPICDEM™ 1.1 Plus Development Board User’s Guide

2.5.1 Identify Assembler Include Path

1. Select the General tab.
2. At the Assembler Include Path, $(AINDIR) box, click Browse... and navigate to:
C:\Program Files\Microchip\MPLAB ASM30 Suite\Support\Inc
This path tells MPLAB IDE where to find the Include files.

2.5.2 Link for ICD 2

1. Select the MPLAB LINK30 tab to view the linker settings (see Figure 2-8).
2. Check Link for ICD 2.
3. Click Apply, then click OK. The text box closes while the linker reserves space for the debug code used by the MPLAB ICD 2.
4. Click OK again to save these changes. The project is now ready to build.
FIGURE 2-8: MPLAB
®
LINK30 BUILD OPTIONS
Check Link for ICD2
DS70099D-page 20 © 2006 Microchip Technology Inc.
Using dsPIC30F Devices

2.5.3 Build the Project

1. Select P r oj ect >B ui ld All.
2. Observe the progress of the build in the Output window (Figure 2-9).
3. When BUILD SUCCEEDED displays you are ready to program the device.
FIGURE 2-9: BUILD OUTPUT WINDOW

2.6 PROGRAMMING THE CHIP

The MPLAB ICD 2 In-Circuit Debugger can be used to program and debug the dsPIC30F6014A device in-circuit on the dsPICDEM™ 1.1 Plus Development Board.
Note: Before proceeding, make sure that the USB driver for the MPLAB ICD 2 has
been installed on your PC (see the “MPLAB DS51331) for more details regarding the installation of MPLAB ICD 2.
Status shows BUILD SUCCEEDED
®
ICD 2 User’s Guide”,
Use the following procedures to program the dsPIC30F6014A device.

2.6.1 Set Up the Device Configuration

1. Use the Configure>Configuration Bits menu to display the configuration settings.
2. Set up the Configuration bits as shown in Figure 2-10.
FIGURE 2-10: CONFIGURATION SETTINGS
© 2006 Microchip Technology Inc. DS70099D-page 21
dsPICDEM™ 1.1 Plus Development Board User’s Guide
The highlighted configuration settings may need to change to the these values: Primary Oscillator Mode: XT w/PLL 4x
Watchdog Timer: Disabled

2.6.2 Connect the MPLAB ICD 2 In-Circuit Debugger

1. Before set ting up the hardware, check that the following jumpers are in place: AVDD_JMP: On
J8: 33F PGD3/30F, 33F PGD3/30F J10: MCLR1 VDD_JMP: On
J21 On (5V) J22 On (5V)
2. Connect the MPLAB ICD 2 to the PC with the USB cable (see Figure 2-11).
3. Connect the MPLAB ICD 2 to the dsPICDEM™ 1.1 Plus Development Board with the short RJ-11 (telephone) cable.
4. Apply power to the board.
FIGURE 2-11: dsPICDEM™ 1.1 PLUS DEVELOPMENT BOARD
CONNECTED TO MPLAB
®
ICD 2 IN-CIRCUIT DEBUGGER
DS70099D-page 22 © 2006 Microchip Technology Inc.
Using dsPIC30F Devices

2.6.3 Enable MPLAB ICD 2 Connection

1. From the Debugger menu, click Select Tool>MPLAB ICD 2 to designate the
MPLAB ICD 2 as the debug tool in MPLAB IDE.
2. From the Debugger
The MPLAB ICD 2 should report that it found the dsPIC30F6014A device, as shown in Figure 2-12.
Note: MPLAB IDE may need to download new firmware if this is the first time the
MPLAB ICD 2 is being used with a dsPIC30F device. Allow it to do so. If any errors are shown, double click the error message to get more information.
menu, select Connect to connect the debugger to the device.
FIGURE 2-12: ENABLING MPLAB
3. From the Debugger
menu, click Settings to display the MPLAB ICD Debugger
®
ICD 2
Status shows that target device has been found
.
settings.
4. Select the Program tab.
5. Check Allow ICD 2 to select memories and ranges, as shown in Figure 2-13.
This setting will speed up operations by programming only a small part of the total program memory.
© 2006 Microchip Technology Inc. DS70099D-page 23
dsPICDEM™ 1.1 Plus Development Board User’s Guide
FIGURE 2-13: SETTING PROGRAM MEMORY SIZE
DS70099D-page 24 © 2006 Microchip Technology Inc.
Loading...
+ 64 hidden pages