Keil™, An ARM® Company

Technical Support

C166: HANDLING UNUSED INTERRUPTS


Information in this article applies to:

  • C166 Version 3.12

QUESTION

We would like to account for all interrupts in a C167 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

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.

SEE ALSO

FORUM THREADS

The following Discussion Forum threads may provide information related to this topic.

Last Reviewed: Monday, May 17, 2004


Did this article provide the answer you needed?
 
Yes
No
Not Sure