Using S12XE processor, and trying to track down the source of an infrequent COP time-out.
I know that the COP timeout forces a reset. What I'd like to do in the COP ISR is look back at the stack frame when the COP occured, particularly the PC. Of course, this will work only if the SP 's value is not changed by the reset.
So, is the stack pointer unchanged across a COP-induced reset?
Thanks!!
Dave Kellogg
Solved! Go to Solution.
Dave,
I checked with design and unfortunately, the stack pointer is reset (cleared) for any reset. This it a difficult problem and one that can generally only be solved with the use of a full in-circuit Emulator with external trace memory. However, the on-chip debug module (S12XDBG) could help you. It can be set up for "Pure PC mode" where all program counter addresses are stored in the trace buffer. Since a reset, other than a POR, does not affect the contents of the trace buffer or the DBGCNT register, the COP reset routine could look at the DBGCNT register and read the appropriate number of entries from the trace buffer.
This should allow you to determine where the code was executing when the COP reset occurred.
Best Regards,
Gordon
Dave,
I checked with design and unfortunately, the stack pointer is reset (cleared) for any reset. This it a difficult problem and one that can generally only be solved with the use of a full in-circuit Emulator with external trace memory. However, the on-chip debug module (S12XDBG) could help you. It can be set up for "Pure PC mode" where all program counter addresses are stored in the trace buffer. Since a reset, other than a POR, does not affect the contents of the trace buffer or the DBGCNT register, the COP reset routine could look at the DBGCNT register and read the appropriate number of entries from the trace buffer.
This should allow you to determine where the code was executing when the COP reset occurred.
Best Regards,
Gordon
Hi Gordon,
Thanks for your response and insight. I had totally forgotten about the trace buffer. The approach makes sense. When I dragged out my old hard copy of the manual, I found a note I had written several years ago about this possiblity.
Dave Kellogg