Keil™, An ARM® Company

Technical Support

GCC: PROBLEMS WITH LOCAL VARIABLES IN INTERRUPTS


Information in this article applies to:

  • GNU C Compiler for ARM Version 3.22

QUESTION

I have a complex interrupt function that uses local variables. It seems that the GNU compiler does not generate correct code for it. Is there a known problem?

My code looks like:

void intr_func (void) __attribute__ ((interrupt));    // Generate Interrupt

void intr_func (void)  {
  int a, b, c, d;

  :   /* function code */
}

ANSWER

Yes, there is a problem in the GNU V3.22 compiler. For the moment, we recommend using the following work-around:

void intr_wrapper (void) __attribute__ ((interrupt));    // Generate Interrupt

void intr_wrapper (void)  {
  intr_func ();
}

Use the wrapper function around the interrupt and the correct code is generated.

Last Reviewed: Monday, July 10, 2006


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