07.04.2013 Views

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

MPLAB C Compiler for PIC24 MCUs and dsPIC DSCs ... - Microchip

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

16-Bit C <strong>Compiler</strong> User’s Guide<br />

The convention in the processor header files is that each SFR is named, using the<br />

same name that appears in the data sheet <strong>for</strong> the part – <strong>for</strong> example, CORCON <strong>for</strong> the<br />

Core Control register. If the register has individual bits that might be of interest, then<br />

there will also be a structure defined <strong>for</strong> that SFR, <strong>and</strong> the name of the structure will be<br />

the same as the SFR name, with “bits” appended. For example, CORCONbits <strong>for</strong> the<br />

Core Control register. The individual bits (or bit fields) are named in the structure using<br />

the names in the data sheet – <strong>for</strong> example PSV <strong>for</strong> the PSV bit of the CORCON<br />

register. Here is the complete definition of CORCON (subject to change):<br />

/* CORCON: CPU Mode control Register */<br />

extern volatile unsigned int CORCON __attribute__((__near__));<br />

typedef struct tagCORCONBITS {<br />

unsigned IF :1; /* Integer/Fractional mode */<br />

unsigned RND :1; /* Rounding mode */<br />

unsigned PSV :1; /* Program Space Visibility enable */<br />

unsigned IPL3 :1;<br />

unsigned ACCSAT :1; /* Acc saturation mode */<br />

unsigned SATDW :1; /* Data space write saturation enable */<br />

unsigned SATB :1; /* Acc B saturation enable */<br />

unsigned SATA :1; /* Acc A saturation enable */<br />

unsigned DL :3; /* DO loop nesting level status */<br />

unsigned :4;<br />

} CORCONBITS;<br />

extern volatile CORCONBITS CORCONbits __attribute__((__near__));<br />

Note: The symbols CORCON <strong>and</strong> CORCONbits refer to the same register <strong>and</strong><br />

will resolve to the same address at link time.<br />

7.4 REGISTER DEFINITION FILES<br />

The processor header files described in Section 7.3 “Processor Header Files” name<br />

all SFR’s <strong>for</strong> each part, but they do not define the addresses of the SFR’s. A separate<br />

set of device-specific linker script files, one per part, is distributed in the support\gld<br />

directory. These linker script files define the SFR addresses. To use one of these files,<br />

specify the linker comm<strong>and</strong>-line option:<br />

-T p30fxxxx.gld<br />

where xxxx corresponds to the device part number.<br />

For example, assuming that there exists a file named app2010.c, which contains an<br />

application <strong>for</strong> the <strong>dsPIC</strong>30F2010 part, then it may be compiled <strong>and</strong> linked using the<br />

following comm<strong>and</strong> line:<br />

pic30-gcc -o app2010.o -T p30f2010.gld app2010.c<br />

The -o comm<strong>and</strong>-line option names the output COFF executable file, <strong>and</strong> the -T<br />

option gives the name <strong>for</strong> the <strong>dsPIC</strong>30F2010 part. If p30f2010.gld is not found in the<br />

current directory, the linker searches in its known library paths. For the default<br />

installation, the linker scripts are included in the PIC30_LIBRARAY_PATH. For<br />

reference see Section 3.6 “Environment Variables”.<br />

DS51284H-page 92 © 2008 <strong>Microchip</strong> Technology Inc.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!