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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7.1 INTRODUCTION<br />

7.2 HIGHLIGHTS<br />

<strong>MPLAB</strong> ® C COMPILER FOR<br />

<strong>PIC24</strong> <strong>MCUs</strong> AND <strong>dsPIC</strong> ® <strong>DSCs</strong><br />

USER’S GUIDE<br />

Chapter 7. Device Support Files<br />

This section discusses device support files used in support of compilation using the<br />

<strong>MPLAB</strong> C <strong>Compiler</strong> <strong>for</strong> <strong>PIC24</strong> <strong>MCUs</strong> <strong>and</strong> <strong>dsPIC</strong> ® <strong>DSCs</strong> (<strong>for</strong>merly <strong>MPLAB</strong> C30).<br />

Items discussed in this chapter are:<br />

• Processor Header Files<br />

• Register Definition Files<br />

• Using SFRs<br />

• Using Macros<br />

• Accessing EEDATA from C Code - <strong>dsPIC</strong>30F dSCs only<br />

7.3 PROCESSOR HEADER FILES<br />

The processor header files are distributed with the language tools. These header files<br />

define the available Special Function Registers (SFR’s) <strong>for</strong> each <strong>dsPIC</strong> DSC device. To<br />

use a header file in C, use;<br />

#include <br />

where xxxx corresponds to the device part number. The C header files are distributed<br />

in the support\h directory.<br />

Inclusion of the header file is necessary in order to use SFR names<br />

(e.g., CORCONbits).<br />

For example, the following module, compiled <strong>for</strong> the <strong>dsPIC</strong>30F2010 part, includes two<br />

functions: one <strong>for</strong> enabling the PSV window, <strong>and</strong> another <strong>for</strong> disabling the PSV window.<br />

#include <br />

void<br />

EnablePSV(void)<br />

{<br />

CORCONbits.PSV = 1;<br />

}<br />

void<br />

DisablePSV(void)<br />

{<br />

CORCONbits.PSV = 0;<br />

}<br />

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

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

Saved successfully!

Ooh no, something went wrong!