Microchip Technology SW006023-1N Scheda Tecnica

Pagina di 238
Interrupts
 2012 Microchip Technology Inc.
DS51686E-page 135
The compiler also supports an IPLnAUTO IPL specifier that uses the run-time value in 
SRSCTL
 to determine whether it should use software or SRS context-saving code. The 
compiler defaults to using IPLnAUTO when the IPL specifier is omitted from the 
interrupt()
 attribute. 
For devices that do not support a shadow register set for interrupt context saving, use 
IPLnSOFT for all interrupt handlers. 
11.3.2
Interrupt Pragma
# pragma interrupt function-name IPLn[AUTO|SOFT|SRS] [vector 
[@]vector-number [, vector-number-list]]
# pragma interrupt function-name  single [vector [@] 0 
Where n is in the range of 0..7, inclusive. 
The IPLn [AUTO|SOFT|SRS] IPL specifier may be all uppercase or all lowercase.
The function definition for a handler function indicated by an interrupt pragma must 
follow in the same translation unit as the pragma itself.
The interrupt attribute will also indicate that a function definition is an interrupt 
handler. It is functionally equivalent to the interrupt pragma.
For example, the definitions of foo below both indicate that it is an interrupt handler 
function for an interrupt of priority 4 that uses software context saving.
#pragma interrupt foo IPL4SOFT
void foo (void)
is functionally equivalent to
void __attribute__ ((interrupt(IPL4SOFT))) foo (void)
11.3.3
__ISR Macros
The <sys/attribs.h> header file provides macros intended to simplify the 
application of attributes to interrupt functions. There are also vector macros defined in 
the processor header files. (See the appropriate header file in the compiler’s 
/pic32mx/include/proc
 directory.)
 
11.3.3.1
__ISR(V, IPL)
Use the __ISR(v, IPL) macro to assign the vector-number location and associate it 
with the specified IPL. This will place a jump to the interrupt handler at the associated 
vector location. This macro also applies the nomips16 attribute since PIC32MX 
devices require that interrupt handlers must use the MIPS32 instruction set.
Note:
SRS
 has the shortest latency and SOFT has a longer latency due to 
registers saved on the stack. AUTO adds a few cycles to test if SRS or SOFT 
should be used.
Note:
The interrupt pragma is provided only for compatibility when porting code 
from other compilers. The interrupt function attribute is the preferred and 
more common way to write an interrupt service routine.