Isr-endIsr

Isr-endIsr defines a Interrupt-Service routine. The routine can be assigned to one of the Controller's interupts such as a Timer or Serial Port.

Syntax:

  • Isr Identifier [Switch (see Table)]
    • [ Dim myVar as static Datatype ]
    • Service Routine program code
  • endIsr

To exit the Serviceroutine, use return.

Switch Description
save Compact save all registers (Default)
nosave No Registers saved, you must handle this in your routine
fastall Save all Registers (Fast, longer Routine)
fastauto The registers are saved automatically. Determined automatically by the optimizer by following the program run (fastest version).

Explanation

save/nosave/fastall: Optional parameter control saving of Registers. On an interrupt, the current program execution is interrupted and the Service Routineis executed. Registers will be modified, which must saved on entering and restored on exit. If you have limited memory or a time critical routine; then you can use nosave to save/restore only Registers that you will modify, or by using fastauto to let the optimizer determine wich registers must be saved.

Special feature fastauto

With the option fastauto the used registers are automatically determined by the optimizer by following the program run.

Important Notes

Interrupt-Service Routines should be kept short without any delay loops, interrupting commands or eeprom access. The Service Routine must be completed before the next Interrupt occurs. Subroutine call are permitted.

Attention when using datatypes who refers to dynamic memory such as string or MemoryBlock. Here you must ensure that there is no simultaneous access in the interrupts-service and main-program. Manipulation of Strings or MemoryBlocks is time consuming and not recommended!

Example

Timer0.isr   = myServiceRoutine  ' Asign Service Routine
Timer0.clock = 1024                 ' Set Prescaler
Timer0.enable                       ' Enable Timer
Avr.Interrupts.enable               ' Enable Globale Interrupts
do
loop
 
Isr myServiceRoutine
  print "Timer-Interrupt activated"
endIsr