INTERRUPT SERVICE ROUTINES
Applies to: C166 C Compiler
Information in this article applies to:
How do I declare an interrupt service routine in C for the Keil
The following line of C code declares an interrupt service
void timer0 (void) interrupt 0x20 using INTREG
void: is the type that is returned from the interrupt
function. Interrupts return nothing and, therefore, have a void
timer0: is the name of the interrupt function. This may
be any valid C function name of your choosing.
(void): is the argument list for the interrupt function.
Interrupts take no arguments, therefore, this is always a void
interrupt: is a C166 keyword that specifies that the
function is an interrupt service routine and that an interrupt
vector should be generated.
0x20: is the trap number for the interrupt. In this
case, 0x20 is the trap number for TIMER0. You can find a listing of
the TRAP numbers in the Infineon or STMicroelectronics User's
using: is a C166 keyword that specifies that this
function uses a register bank. This is good to use (but it is not
required) in an interrupt service routine to avoid pushing and
popping the registers from the stack. Instead, the new register
bank is used as the storage area for the general purpose
INTREG: is the name of the register bank to use.
Basically, this is a name that you can make up. There are no naming
conventions for it. But, as a general rule, you should use a
different register bank for each interrupt routine.
Article last edited on: 2005-11-17 15:48:29
Rate this article
Disagree? Move your mouse over the bar and click