Keil Logo

C166: INTERRUPT SERVICE ROUTINES


Information in this article applies to:

  • C166 All Versions

QUESTION

How do I declare an interrupt service routine in C for the Keil C166 Compiler?

ANSWER

The 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 INFORMATION

Last Reviewed: Thursday, November 17, 2005


Did this article provide the answer you needed?
 
Yes
No
Not Sure
 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.