SW006012 Microchip Technology, SW006012 Datasheet - Page 67

C COMPILER FOR DSPIC30F FAMILY

SW006012

Manufacturer Part Number
SW006012
Description
C COMPILER FOR DSPIC30F FAMILY
Manufacturer
Microchip Technology
Type
MPLAB® C30 Compilerr
Series
PIC24 & DsPICr
Datasheets

Specifications of SW006012

Supported Families
PIC24, DsPIC30F And DsPIC33F
Core Architecture
PIC, DsPIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC24 MCUs And DsPIC DSCs
Tool Type
Compiler
Processor Series
PIC24, dsPIC
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
dsPIC30F
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
3.9
© 2007 Microchip Technology Inc.
COMPILING MULTIPLE FILES ON THE COMMAND LINE
• c:\Program Files\Microchip\MPLAB C30\support\h - Include directory
• c:\Program Files\Microchip\MPLAB C30\lib - Library directory: this
• c:\Program Files\Microchip\MPLAB C30\support\gld - Linker script
• c:\Program Files\Microchip\MPLAB C30\bin - Executables directory:
The following is a simple C program that adds two numbers.
Create the following program with any text editor and save it as ex1.c.
#include <p30f2010.h>
int main(void);
unsigned int Add(unsigned int a, unsigned int b);
unsigned int x, y, z;
int
main(void)
{
}
unsigned int
Add(unsigned int a, unsigned int b)
{
}
The first line of the program includes the header file p30f2010.h, which provides
definitions for all special function registers on that part. For more information on header
files, see Chapter 6. “Device Support Files”.
Compile the program by typing the following at a DOS prompt:
C:\> pic30-gcc -o ex1.o ex1.c
The command-line option -o ex1.o names the output COFF executable file (if the -o
option is not specified, then the output file is named a.exe). The COFF executable file
may be loaded into the MPLAB IDE.
If a hex file is required, for example to load into a device programmer, then use the
following command:
C:\> pic30-bin2hex ex1.o
This creates an Intel hex file named ex1.hex.
Move the Add() function into a file called add.c to demonstrate the use of multiple
files in an application. That is:
File 1
/* ex1.c */
#include <p30f2010.h>
int main(void);
unsigned int Add(unsigned int a, unsigned int b);
for dsPIC® DSC device-specific header files. This directory is where the compiler
stores the dsPIC DSC device-specific header files. The
PIC30_C_INCLUDE_PATH environment variable can point to that directory.
(From the DOS command prompt, type set to check this.)
directory is where the libraries and precompiled object files reside.
directory: this directory is where device-specific linker script files may be found.
this directory is where the compiler programs are located. Your PATH environment
variable should include this directory.
x = 2;
y = 5;
z = Add(x,y);
return 0;
return(a+b);
Using MPLAB C30 C Compiler
DS51284F-page 61

Related parts for SW006012