Hi Pierre,
I suppose that restoration of the context when code goes out from the Interrupt routine is not a root cause of your issue.
But, back to your questions:
1. Yes, MCU automatically stores and restore context at entering and exit of an interrupt routine. However, the context here means just core registers = CCRH:CCRL, B:A, X, Y, and the return address (CCRH just for S12X core).
By compiler/linker settings we could also automatically stack page registers (this is software solution - compiler just generates code for that).
See S12X CPU reference manual for more details about interrupt processing:
http://www.nxp.com/files/microcontrollers/doc/ref_manual/S12XCPUV2.pdf
2. No, stacking core registers cannot be disabled. It is the natural behavior of core in case of the interrupt. In fact, the pull from the stack is managed by RTI instruction (generated by compiler/linker at an end of interrupt routine). So, you could create your own interrupt routine which will be ended by different instruction than RTI. However I don’t see any advantage of that solution for now – rather plenty of additional possible issues (memory leak, code run away, locked interrupts,…)
I suppose that your issue will be based on the different root cause.
Please sue breakpoints, watchpoints, LEDs, debug variables and other tools for deeper debugging.
I hope it helps you.
Have a great day,
Radek
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------