|
|||||||||||
Technical Support Support Resources
Product Information |
C51: Calling Functions from InterruptsInformation in this article applies to:
QUESTIONI have created an interrupt service routine as follows:
which calls another function declared as follows:
The code inside the doit function fails and causes strange results. What's going on? ANSWERYour interrupt service routine operates in register bank 1. The doit function, however, assumes register bank 0. This is the problem. The reason this is a problem has to do with the way the compiler generates register to register move instructions. On the 8051, there is no register to register move. So, the compiler generates register to memory moves instead. Since the compiler knows the register bank, the physical address of a register in a register bank can be calculated. For example, when the compiler calculates the address of R2 in register bank 0, the address is 0x02. If the register bank selected is not really 0, then the function overwrites this register and another part of the program will likely crash. This technique of accessing a register using its absolute address is called absolute register addressing. In the example above, the doit function is looking in the wrong place for its register values. To solve this problem, you may do one of the following:
SEE ALSO
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.