|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Interrupts and Local VariablesInformation in this article applies to:
QUESTIONI 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). ANSWERInterrupts 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.
MORE INFORMATION
Last Reviewed: Thursday, February 25, 2021 | ||||||||||
|
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.