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
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 />
For example, to declare two variables that retain their values across a device reset:<br />
int _PERSISTENT var1,var2;<br />
7.6.4 ISR Declaration Macros<br />
The following macros can be used to declare Interrupt Service Routines (ISRs):<br />
#define _ISR __attribute__((interrupt))<br />
#define _ISRFAST __attribute__((interrupt, shadow))<br />
For example, to declare an ISR <strong>for</strong> the timer0 interrupt:<br />
void _ISR _INT0Interrupt(void);<br />
To declare an ISR <strong>for</strong> the SPI1 interrupt with fast context save:<br />
void _ISRFAST _SPI1Interrupt(void);<br />
Note: ISRs will be installed into the interrupt vector tables automatically if the<br />
reserved names listed in Section 8.4 “Writing the Interrupt Vector” are<br />
used.<br />
7.7 ACCESSING EEDATA FROM C CODE - <strong>dsPIC</strong>30F DSCS ONLY<br />
The compiler provides some convenience macro definitions to allow placement of data<br />
into the devices EE data area. This can be done quite simply:<br />
int _EEDATA(2) user_data[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };<br />
user_data will be placed in the EE data space reserving 10 words with the given initial<br />
values.<br />
The <strong>dsPIC</strong> DSC device provides two ways <strong>for</strong> programmers to access this area of<br />
memory. The first is via the program space visibility window. The second is by using<br />
special machine instructions (TBLRDx).<br />
7.7.1 Accessing EEDATA via the PSV<br />
The compiler normally manages the PSV window to access constants stored in<br />
program memory. If this is not the case, the PSV window can be used to access<br />
EEDATA memory.<br />
To use the PSV window:<br />
• The PSVPAG register must be set to the appropriate address <strong>for</strong> the program<br />
memory to be accessed. For EE data this will be 0xFF, but it is best to use the<br />
__builtin_psvpage() function.<br />
• The PSV window should also be enabled by setting the PSV bit in the CORCON<br />
register. If this bit is not set, uses of the PSV window will always read 0x0000.<br />
DS51284H-page 96 © 2008 <strong>Microchip</strong> Technology Inc.