User manual

mikroBasic PRO for PIC32
MikroElektronika
141
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:
sub procedure interrupt() org 0x9D000000 iv IVT_ADC ilevel 7 ics ICS_SOFT
‘ Interrupt service routine code
end sub
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.
Use the DisableContextSaving 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.
This enables the user to manually write code for saving registers upon entrance and to restore them before exit from
interrupt.