Previous page Table of contents Next page
Getting Started:
Creating your first MPLAB project for PIC24F microcontrollers
on-line
 

In this chapter we will show you the steps that you need to do in order to create your first PIC24F application.

Before starting, you need to have the MPLAB IDE and a C compiler for PIC24F microprocessor installed on your computer. Microchip is providing for free the MPLAB IDE and a student version of their C30 compiler. These are available for download on the Microchip website.

I’m using the MPLAB v8.15a (the latest version of the IDE at the time when I’m writing this article) and a full version of the C30 compiler, but the student version should work well for you at this stage (please read and be sure you understand the conditions of the student version before starting).

Bellow is a capture from the MPLAB IDE without any project loaded.

Creating your first MPLAB project for PIC24F

STEP 1: Creating a project

The first step is to create a new project. To do this, go to the ‘Project’ menu and click the ‘New’ submenu.

Creating your first MPLAB project for PIC24F

A new window will open, asking you for the name and location of the project:

Creating your first MPLAB project for PIC24F

In the ‘Project View’, you will be able to see the name of your project, and all the files that are included. As you can see, at this step, our new project does not contain any file.

In the ‘Output View’, different information, errors and warnings will be displayed. Be sure you always keep an eye on this section of the MPLAB IDE.

To enable these sections, you must go to the ‘View’ menu, and click the ‘Project’ and ‘Output’ submenus.

Creating your first MPLAB project for PIC24F

STEP 2: Configuring the project

Next, you must specify the target microprocessor you want to use in this project. To do this, you must go to the ‘Configure’ menu, and click the ‘Select Device’ submenu.

Creating your first MPLAB project for PIC24F

A new window will open showing you different information about the microprocessor you want to use:

In this project I want to use a PIC24FJ128GA010 device, and I selected it from the first drop-down list. Bellow you can see how this device is supported by different programmers, debuggers and design tools. The meaning of the different colors is: red for ‘Not Supported’, yellow for ‘Beta Support’ and green for ‘Production Testing’.

Creating your first MPLAB project for PIC24F

Next, you must take care of the configuration bits. The configuration bits are special bits, located on a special section of the program memory. On device reset, this configuration bits are automatically copied to the microprocessor configuration registers. At this point you don’t need to care too much about this aspect, but you must be aware that they exist and they play an important role in the microprocessor behavior.

Creating your first MPLAB project for PIC24F

When you click the ‘Configuration Bits’ submenu, a new window will open where you have two options: either you set the configuration bits from this dialog window, or you set them in the code with special keywords. I prefer the second option and I will show you how to do this.

Creating your first MPLAB project for PIC24F

Next, you should check that your project has the correct language tool suite selected. The reason for doing this is because the MPLAB IDE can use multiple tool suites allowing you to easily switch your project from a device family to another.

In order to check this, you must go to the ‘Project’ menu, and click the ‘Select Language Toolsuite’ submenu.

Creating your first MPLAB project for PIC24F

Microchip C30 Toolsuite is the one that need to be selected for PIC24F devices.

Creating your first MPLAB project for PIC24F

STEP 3: Adding files to the project

Now that you have a project created and configured, probably you will want to add files to the project. In order to do this, you have two options: either from the ‘Project’ menu, either you right click on the project name in the ‘Project View’.

For this tutorial, I want to add only a single file containing the main function, with some dummy C code inside.

Creating your first MPLAB project for PIC24F

STEP 4: Building the project

To build the project, you simply click the ‘Build All’ button on the toolbar, or you go to ‘Project’ menu and click the ‘Build All’ submenu. The status of the build operation is displayed in the ‘Output View’. If you have no errors, and the build is correctly done, a hex file is generated. The default location for the hex file is the project folder on your computer.

Creating your first MPLAB project for PIC24F

Previous page Table of contents Next page
 

© Copyright 2008 - 2009 pic24micro.com All Rights Reserved.