26-12-2012, 02:37 PM
MPLAB C30 C COMPILER USER’S GUIDE
1MPLAB C30.pdf (Size: 2.13 MB / Downloads: 39)
INTRODUCTION
The dsPIC® family of Digital Signal Controllers (DSC) combines the high performance
required in DSP applications with standard microcontroller features needed for
embedded applications. Additional high-performance microcontrollers (MCU) without
DSP are also available for other applications.
All of these devices are fully supported by a complete set of software development
tools, including an optimizing C compiler, an assembler, a linker and an archiver/
librarian.
This chapter provides an overview of these tools and introduces the features of the
optimizing C compiler, including how it works with the MPLAB ASM30 assembler and
MPLAB LINK30 linker. The assembler and linker are discussed in detail in the
“MPLAB® ASM30, MPLAB LINK30 and Utilities User's Guide”, (DS51317).
HIGHLIGHTS
Items discussed in this chapter are:
• MPLAB C30 Description
• MPLAB C30 and Other Development Tools
• MPLAB C30 Feature Set
MPLAB C30 DESCRIPTION
MPLAB C30 is an ANSI x3.159-1989-compliant, optimizing C compiler that includes
language extensions for dsPIC DSC embedded-control applications. The compiler is a
Windows® console application that provides a platform for developing C code. The
compiler is a port of the GCC compiler from the Free Software Foundation.
MPLAB C30 AND OTHER DEVELOPMENT TOOLS
MPLAB C30 compiles C source files, producing assembly language files. These
compiler-generated files are assembled and linked with other object files and libraries
to produce the final application program in executable COFF or ELF file format. The
COFF or ELF file can be loaded into the MPLAB IDE, where it can be tested and
debugged, or the conversion utility can be used to convert the COFF or ELF file to
Intel® hex format, suitable for loading into the command-line simulator or a device
programmer. See Figure 1-1 for an overview of the software development data flow.
MPLAB C30 FEATURE SET
The MPLAB C30 C compiler is a full-featured, optimizing compiler that translates
standard ANSI C programs into dsPIC DSC assembly language source. The compiler
also supports many command-line options and language extensions that allow full
access to the dsPIC DSC device hardware capabilities, and affords fine control of the
compiler code generator. This section describes key features of the compiler.
ANSI C Standard
The MPLAB C30 compiler is a fully validated compiler that conforms to the ANSI C
standard as defined by the ANSI specification and described in Kernighan and
Ritchie's, “The C Programming Language (second edition)”. The ANSI standard
includes extensions to the original C definition that are now standard features of the
language. These extensions enhance portability and offer increased capability.
Optimization
The compiler uses a set of sophisticated optimization passes that employ many
advanced techniques for generating efficient, compact code from C source. The
optimization passes include high-level optimizations that are applicable to any C code,
as well as dsPIC DSC device-specific optimizations that take advantage of the particular
features of the dsPIC DSC device architecture.
ANSI Standard Library Support
MPLAB C30 is distributed with a complete ANSI C standard library. All library functions
have been validated, and conform to the ANSI C library standard. The library includes
functions for string manipulation, dynamic memory allocation, data conversion, timekeeping
and math functions (trigonometric, exponential and hyperbolic). The standard
I/O functions for file handling are also included, and, as distributed, they support full
access to the host file system using the command-line simulator. The fully functional
source code for the low-level file I/O functions is provided in the compiler distribution,
and may be used as a starting point for applications that require this capability.
Flexible Memory Models
The compiler supports both large and small code and data models. The small code
model takes advantage of more efficient forms of call and branch instructions, while the
small data model supports the use of compact instructions for accessing data in SFR
space.
The compiler supports two models for accessing constant data. The “constants in data”
model uses data memory, which is initialized by the runtime library. The “constants in
code” model uses program memory, which is accessed through the Program Space
Visibility (PSV) window.