Hi,
I'm using a MC9S12XF512 microcontroller for a FlexRay application.
When I receive a FlexRay frame, I have an interrupt routine which store in variable the payload of the frame. I would like to use this variable in my main() program but it is like nothing have been doing. I think it is due to a restoration of the context when I go out from the Interrupt routine but there is nothing in my code which can do something like that. So I have two questions :
1. Is it the microcontroller which does by itself the storage and the restoration of the context ?
2. Is it possible to bypass this procedure to allow me to reuse my variable in the main() after the modification in the interrupt routine ?
Thank you.
Pierre
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!
-----------------------------------------------------------------------------------------------------------------------