Mikroelektronika MIKROE-738 Datenbogen

Seite von 682
mikroC PRO for PIC32
MikroElektronika
143
where: 
 
iv
 - reserved word that inform the compiler that it is an interrupt service routine. 
 
IVT_ADC
 - appropriate Interrupt Vector. 
 
ilevel
 7 - Interrupt priority level 7. 
 
ics
 Interrupt Context Saving; Interrupt Context Saving can be performed in several ways: 
 
 
1. 
ICS_SOFT
 - Context saving is carried out by the software. 
 
 
2. 
ICS_SRS
 - Shadow Register set is use for context saving. 
 
 
3. 
ICS_OFF
 - No context saving 
 
 
4.
 ICS_AUTO
 - Compiler chooses whether the 
ICS_SOFT
 or 
ICS_SRS
 will be used. 
User can explicitly declare starting interrupt routine address using 
org
 directive:
void interrupt() org 0x9D000000 iv IVT_ADC ilevel 7 ics ICS_SOFT {
  // Interrupt service routine code
}
Function Calls from Interrupt
Calling functions from within the interrupt routine is possible. The compiler takes care about the registers being used, 
both in “interrupt” and in “main” thread, and performs “smart” context-switching between two of them, saving only the 
registers that have been used in both threads. It is not recommended to use a function call from interrupt. In case of 
doing that take care of stack depth. 
Disable Context Saving
Use the 
#pragma disablecontexsaving
 to instruct the compiler not to automatically perform context-switching. 
This  means  that  no  register  will  be  saved/restored  by  the  compiler  on  entrance/exit  from  interrupt  service  routine, 
except STATUS, WREG and BSR registers in high priority interrupt (‘Fast Register Stack’).
This exception can be overrided by placing an 
asm  RETFIE,  0
 instruction at the end of the high priority interrupt 
routine (with redirecting all routine exits to this instruction). 
Thus, 
#pragma disablecontexsaving
 pragma enables the user to manually write code for saving registers upon 
entrance and to restore them before exit from interrupt.