USING MULTIPLE PROJECTS IN A SINGLE WORKSPACE

4.9 USING MULTIPLE PROJECTS IN A SINGLE WORKSPACE

You may wish to have multiple projects in one workspace. This makes use of one workspace setup (i.e., selected device, debug tool, window setups, etc.) for many projects.

Some applications can benefit from using more than one project in a workspace. Consider the following examples.

EXAMPLE 4-1:

BOOTLOADER

A bootloader has its own source code and its only function is to download and program

a new version of an application in flash memory. The bootloader would always exist in

a fixed location in program memory, and would be executed by a special function of the application. The bootloader would then download a program through a communica- tions port and overwrite the existing application with an new version. Both the boot- loader and the application share the same settings for the dsPIC30F device since they will exist on the same part, but they are independent pieces of code. The application knows only the entry address for executing the bootloader. The bootloader knows only the start address for the upgrade code.

EXAMPLE 4-2:

TESTS

Another use of multiple projects is when developing a series of tests for a single application. These tests might exist in the same locations in program memory, but never be loaded simultaneously.

EXAMPLE 4-3:

APPLICATION CONFIGURATION

A third possibility is that the application has multiple configurations for the end product. An application might be sold under multiple brands or with alternate languages. Each project could contain the branding information or language strings for the application in

a separate resource file.

 2005 Microchip Technology Inc.

DS51519A-page 71

MPLAB ® IDE User’s Guide

4.9.1 Setting Up Multiple Projects

To set up the workspace to use multiple projects:

1. Select the device you will use for development (Configure>Select Device).

2. Create/open and set up the first project in the current workspace.

3. Make sure that the following options are selected. Then repeat #2 for each project you wish to add to the workspace.

• Configure>Settings, Projects tab: uncheck “Use one-to-one project-

workspace model” • Configure>Settings, Program Loading tab: check “Clear program memory

upon loading a program”

4. Make a project active by selecting Project>Set Active Project>projectname.mcp, where projectname.mcp is the project name, or right-click on the project in the Project window and select Set As Active Project. The project name will appear bolded in the Project window.

5. Build the active project. • To build the whole project, right-click on the project name in the Project

window and select Build All. • To build only the files that have changed in a project, right-click on the project

name in the Project window and select Make. Your application is now ready to debug. When your debug session is complete: • Save the current active project by selecting Project>Save Project or by

right-clicking on the project in the Project window and selecting Save Project. • Select another project as the active project, build this project and debug. • Remove the active project from the workspace by selecting Project>Close or by

right-clicking on the project in the Project window and selecting Close Project. • Close and save all projects and the associated workspace by selecting File>Close

Workspace. You will be prompted to save. • Reopen all projects and the associated workspace by selecting File>Open

Workspace.

4.9.2 Determining an Active Project

An active project is the project in the workspace that the following Project menu and toolbar commands will act on:

• Clean • Find in Project Files • Save Project • Add Files to Project • Select Language Toolsuite

All other Project menu, toolbar and right mouse menu commands will act on the project specified when the command is chosen. As an example, if you right-click on a project in the Project window that is not the active project, you can build this project by selecting Build All or Make and this project's build results will be loaded into program memory.

To avoid confusion, it is recommended that you make active a project you will be developing and building.

DS51519A-page 72

 2005 Microchip Technology Inc.

Projects and Workspaces

The last project opened in a workspace will automatically be set as the active project. To set a project as the active project, select Project>Set Active Project> project- name.mcp, where projectname.mcp is the project name, or right-click on the project in the Project window and select Set As Active Project. The project name will appear in bold in the Project window.

4.9.3 Using Concurrent Projects

You may wish to have multiple projects that create code to occupy different regions of program memory, thus creating one application. Projects used this way are considered concurrent projects.

To create a concurrent-projects workspace:

1. Begin with a multiproject workspace.

2. Uncheck the “Clear program memory upon loading a program” option on the Configure>Settings, Program Loading tab.