Mikroelektronika MIKROE-350 Fiche De Données

Page de 526
INTERRUPTS
AVR derivates acknowledges an interrupt request by executing a hardware gener-
ated CALL to the appropriate servicing routine ISRs. ISRs are organized in IVT. ISR
is defined as a standard function but with the 
org
directive afterwards which con-
nects the function with specific interrupt vector. For example org 0x000B is IVT
address of Timer/Counter 2 Overflow interrupt source of the ATMEGA16. 
For more information on interrupts and IVT refer to the specific data sheet. 
Function Calls from Interrupt
Calling functions from within the interrupt routine is allowed. The compiler takes care
about the registers being used, both in "interrupt" and in "main" thread, and performs
"smart" context-switching between them two, saving only the registers that have
been used in both threads. It is not recommended to use function call from interrupt.
In case of doing that take care of stack depth. 
sub procedure Interrupt() org 0x16 
RS485Master_Receive(dat)
end 
sub
Most of the MCUs can access interrupt service routines directly, but some can not
reach interrupt service routines if they are allocated on addresses greater than 2K
from the IVT. In this case, compiler automatically creates Goto table, in order to jump
to such interrupt service routines.
92
MIKROELEKTRONIKA
- SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Specifics
mikroBasic PRO for AVR
CHAPTER 3