by aolofsson » Wed Dec 18, 2013 8:47 pm
alex,
As tim and others guessed, the RTI instruction does not care if the program is in an ISR or not.(as a lowly hardware designer I had to think about what that meant:D)
This is what happens when an RTI instruction is executed:
1.) the PC jumps to the address in the IRET register
2.) status[1] is cleared, enabling interrupts
3.) The IPEND bit of the ISR currently being executed is cleared. If the IPEND register is all zero (no ISR), there is nothing to clear.
4.)...undocumented, untested, and unsupported....status[2], user/kernel mode is set to user mode=0. (you can probably ignore this for now, I can give more information if someone thinks a user/kernel mode might be useful..) To enable user/kernel mode, set bit [25] of the CONFIG register.
Andreas