MPLAB ? C32 C Compiler User’s Guide
1.9
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
directory for standard C header files.
? c:\Program Files\Microchip\MPLAB C32\pic32mx\include proc -
Include directory for PIC32MX device-specific header files.
? c:\Program Files\Microchip\MPLAB C32\pic32mx\lib - Library
directory structure for standard libraries and startup files.
? c:\Program Files\Microchip\MPLAB
C32\pic32mx\include peripheral - Include directory for PIC32MX
peripheral library include files.
? c:\Program Files\Microchip\MPLAB C32\pic32mx\lib\proc -
Directory for device-specific linker script fragments, register definition files and
configuration data may be found.
? c:\Program Files\Microchip\MPLAB C32\bin - Directory where the top
level tools executables are located. The PATH environment variable may include
this 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 <p32xxxx.h>
unsigned int x, y, z;
unsigned int
add(unsigned int a, unsigned int b)
{
return(a+b);
}
int
main(void)
{
x = 2;
y = 5;
z = add(x,y);
return 0;
}
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 .
DS51686A-page 40
? 2007 Microchip Technology Inc.
相关PDF资料
SW300003-EVAL LIBRARY SOFT MODEM-EVAL ONLY
SW300010-EVAL SPEECH RECOG LIBRARY-EVAL ONLY
SW300040-EVAL LIBRARY NOISE SUPPR-EVAL ONLY
SW300060-EVAL LIBRARY ACOUSTIC ECHO-EVAL ONLY
SW300070-EVAL SOFTWARE LIBR ENC/DEC EVAL ONLY
SW500012 HI-TECH C PRO FOR PIC32
SY87701LHI-EVAL BOARD EVAL SY87701 EXPERIMENT
SY87729LHI-EVAL BOARD EVAL N SY87729 EXPERIMENT
相关代理商/技术参数
SW006021-1 制造商:Microchip Technology 功能描述:MPLAB XC8 STANDARD COMPILER 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STD 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STANDARD 制造商:Microchip Technology Inc 功能描述:COMPILER, MPLAB XC8, STANDARD 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 ANSI C Compiler for the PIC10 (12),(16),(18) (Workstation License) 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 Standard Compiler 制造商:Microchip Technology Inc 功能描述:OPTOCOUPLERS; Core Architecture:PIC; Software Edition:Standard
SW006021-1N 制造商:Microchip Technology 功能描述:MPLAB XC8 STANDARD COMPILER (F 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 STANDARD COMPILER (FLOATING LICENSE) - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 STD FLOAT LIC 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 Standard Compiler (Fltng Lic)
SW006021-2 制造商:Microchip Technology 功能描述:MPLAB XC8 PRO COMPILER WORKSTATION LICENSE 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 PRO COMPILER - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 PRO 制造商:Microchip Technology Inc 功能描述:COMPILER, MPLAB XC8, PRO 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 ANSI PRO Compiler for the PIC10 (12),(16),(18) (Workstation License) 制造商:Microchip Technology Inc 功能描述:MPLAB XC8 PRO Compiler 制造商:Microchip Technology Inc 功能描述:SOFTWARE TOOL, MPLAB XC8 PRO COMPILER; Core Architecture:PIC; Supported Families:PIC10, PIC16, PIC18; Software Edition:Linux; License Type:Floating - node; No. of User Licenses:1; Supported Hosts:-
SW006021-2C 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC8 PRO CHI
SW006021-2N 功能描述:开发软件 MPLAB XC8 PRO Compiler (Fltng Lic) RoHS:否 制造商:Atollic Inc. 产品:Compilers/Debuggers 用于:ARM7, ARM9, Cortex-A, Cortex-M, Cortex-R Processors
SW006022-1 制造商:Microchip Technology 功能描述:MPLAB XC16 STANDARD COMPILER 制造商:Microchip Technology Inc 功能描述:MPLAB XC16 STANDARD COMPILER - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC16 STD 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC16 STANDARD 制造商:Microchip Technology Inc 功能描述:COMPILER, MPLAB XC16, STANDARD 制造商:Microchip Technology Inc 功能描述:MPLAB XC16 Standard Compiler (Workstation License) 制造商:Microchip Technology Inc 功能描述:OPTOCOUPLERS; Core Architecture:PIC, dsPIC; Software Edition:Standard
SW006022-1N 制造商:Microchip Technology 功能描述:MPLAB XC16 STANDARD COMPILER ( 制造商:Microchip Technology Inc 功能描述:MPLAB XC16 STANDARD COMPILER (FLOATING LICENSE) - Boxed Product (Development Kits) 制造商:Microchip Technology Inc 功能描述:COMPILER MPLAB XC16 FLOAT LIC 制造商:Microchip Technology Inc 功能描述:MPLAB XC16 Standard Compiler (Fltng Lic)
SW006022-2 功能描述:开发软件 MPLAB XC16 PRO Compiler RoHS:否 制造商:Microchip Technology 产品: 用于: