Keil Logo

C166: Handling Unused Interrupts


Information in this article applies to:

  • C166 All Versions

QUESTION

We would like to account for all interrupts in a C167/XC16x/XC2000 system - i.e. all unused interrupts would go to a common interrupt routine for logging or error handling. How do we do this? We see how to assign individual interrupt routines to the "table", but not how to load the same vector/function for multiple interrupt sources.

ANSWER

The solution depends on the C166 version you are using.

C166 < 4.10a:

There is no easy way (in C) to assign a single interrupt routine to multiple traps or vectors. However, you can easily implement several interrupt routines that invoke a general purpose unused interrupt handler.

For example, the following code shows you how to trap and "handle" the serial transmit and receive interrupts. Note that these interrupts use the same register bank. This may be undesirable.

void unused_IRQ_handler (
  unsigned int trap_number)
{
/*** Bad IRQ Handler Code Goes Here ***/

  while (1)  /*** delay forever ***/
  {
  }
}


void serial_TX_irq (void) interrupt S0TINT = 42
                          using UNUSED_IRQ_REGBANK
{
  unused_IRQ_handler (42);
}


void serial_RX_irq (void) interrupt S0RINT = 43
                          using UNUSED_IRQ_REGBANK
{
  unused_IRQ_handler (43);
}

Note that in this example, the interrupt functions pass the trap number to the bad IRQ handler. This may or may not be useful depending on your application.

C166 > 4.10a:

With version 4.10a, the L166 linker directive INTNO (interrupt_name (FILL)) was introduced. This directs all unused interrupt vectors to one common interrupt service routine.

Example interrupt service routine:

void interrupt_trap (void) interrupt MYINT
{
  while (1);
}

Example L166 linker directive:

L166 myfile.obj INTNO (MYINT (FILL))

In µVision, you can specify the directive INTNO (MYINT (FILL)) in the dialog Options for Target - L166 Misc - Misc Controls.

L166 myfile.obj INTNO (MYINT (FILL))

MORE INFORMATION

  • Refer to INTNO in the L166 User's Guide.

SEE ALSO


Last Reviewed: Thursday, February 25, 2021


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.