Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 194 2012-2013 Microchip Technology Inc.
The optional irq parameter allows you to place an interrupt vector at a specific
interrupt, and the optional altirq parameter allows you to place an interrupt vector at
a specified alternate interrupt. Each parameter requires a parenthesized interrupt ID
number. (See Section 14.4 Specifying the Interrupt Vector for a list of interrupt
IDs.)
The optional preprologue parameter allows you to insert assembly-language
statements into the generated code immediately before the compiler-generated
function prologue.
When using the interrupt attribute, please specify either auto_psv or no_au-
to_psv. If none is specified a warning will be produced and auto_psv will be
assumed.
14.3.3 Coding ISRs
The following prototype declares function isr0 to be an interrupt handler:
void __attribute__((__interrupt__,__auto_psv__)) isr0(void);
As this prototype indicates, interrupt functions must not take parameters nor may they
return a value. The compiler arranges for all working registers to be preserved, as well
as the Status register and the Repeat Count register, if necessary. Other variables may
be saved by naming them as parameters of the interrupt attribute. For example, to
have the compiler automatically save and restore the variables, var1 and var2, use
the following prototype:
void __attribute__((__interrupt__,__auto_psv__
(__save__(var1,var2)))) isr0(void);
To request the compiler to use the fast context save (using the push.s and pop.s
instructions), tag the function with the shadow attribute (see Section 13.2.1 Function
Specifiers). For example:
void __attribute__((__interrupt__,__auto_psv__, __shadow__))
isr0(void);
14.3.4 Using Macros to Declare Simple ISRs
If an interrupt handler does not require any of the optional parameters of the interrupt
attribute, then a simplified syntax may be used. The following macros are defined in the
device-specific header files:
#define _ISR __attribute__((interrupt))
#define _ISRFAST
__attribute__((interrupt, shadow))
For example, to declare an interrupt handler for external interrupt 0:
#include <xc.h>
void _ISR _INT0Interrupt(void);
To declare an interrupt handler for the SPI1 interrupt with fast context save:
#include <xc.h>
void _ISRFAST _SPI1Interrupt(void);

e-Highlighter

Click to send permalink to address bar, or right-click to copy permalink.

Un-highlight all Un-highlight selectionu Highlight selectionh