SW006015 Microchip Technology, SW006015 Datasheet - Page 44

C COMPILER MPLAB C32

SW006015

Manufacturer Part Number
SW006015
Description
C COMPILER MPLAB C32
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC32r
Datasheets

Specifications of SW006015

Supported Families
PIC32MX5, MX6, And MX7
Core Architecture
PIC
Kit Contents
Software And Docs
Mcu Supported Families
PIC32 MCUs
Tool Function
Compiler
Supported Devices
PIC32 MCUs
Tool Type
Compiler
Processor Series
PIC32
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC32
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
1.9
DS51686A-page 40
COMPILING A SINGLE FILE ON THE COMMAND LINE
®
This section demonstrates how to compile and link a single file. For the purpose of this
discussion, it is assumed the compiler is installed on your c: drive in a directory called
Program Files\Microchip\MPLAB C32. Therefore the following applies:
• c:\Program Files\Microchip\MPLAB C32\pic32mx\include - Include
• c:\Program Files\Microchip\MPLAB C32\pic32mx\include\proc -
• c:\Program Files\Microchip\MPLAB C32\pic32mx\lib - Library
• c:\Program Files\Microchip\MPLAB
• c:\Program Files\Microchip\MPLAB C32\pic32mx\lib\proc -
• c:\Program Files\Microchip\MPLAB C32\bin - Directory where the top
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 <p32xxxx.h>
unsigned int x, y, z;
unsigned int
add(unsigned int a, unsigned int b)
{
}
int
main(void)
{
}
The first line of the program includes the header file p32xxxx.h, which provides
definitions for all special function registers on that part. For more information on
processor header files, see Chapter 4. “Low Level Processor Control”.
Compile the program by typing the following at a DOS prompt:
C:\> pic32-gcc -o ex1.out ex1.c
The command line option -o ex1.out names the output executable file (if the -o
option is not specified, then the output file is named a.out). The 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:\> pic32-bin2hex ex1.out
This creates an Intel hex file named ex1.hex.
directory for standard C header files.
Include directory for PIC32MX device-specific header files.
directory structure for standard libraries and startup files.
C32\pic32mx\include\peripheral - Include directory for PIC32MX
peripheral library include files.
Directory for device-specific linker script fragments, register definition files and
configuration data may be found.
level tools executables are located. The PATH environment variable may include
this directory.
return(a+b);
x = 2;
y = 5;
z = add(x,y);
return 0;
© 2007 Microchip Technology Inc.

Related parts for SW006015