|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
I don't want an ISR to destroy the contents of variables in the main program that it is interrupting. Can I declare variables inside an interrupt routine or do all the variables that the ISR uses have to be global variables (declared outside the routine)?
Also, what about subroutines that the ISR calls? Can they have their own local variables? (assuming the subroutines use the same register bank, of course).
Interrupts may have local variables just like normal functions. Higher levels of optimization in the compiler will move variables automatically into the registers, thus saving them when an interrupt triggers.
Use the following techniques to prevent "corruption" of your DATA space by interrupts.
Article last edited on: 2006-10-24 11:44:12
Did you find this article helpful? Yes No
How can we improve this article?