|
Technical Support Support Resources Product Information | C166: INTERRUPT SERVICE ROUTINES
Information in this article applies to:
QUESTIONHow do I declare an interrupt service routine in C for the Keil C166 Compiler? ANSWERThe following line of C code declares an interrupt service routine:
void timer0 (void) interrupt 0x20 using INTREG
where... - void: is the type that is returned from the interrupt function. Interrupts return nothing and, therefore, have a void return type.
- 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 argument list.
- 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 Manuals.
- 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 registers.
- 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.
MORE INFORMATIONLast Reviewed: Thursday, November 17, 2005
|
|