AnsweredAssumed Answered

Detecting debug mode at run-time

Question asked by Daniel White on Sep 11, 2009
Latest reply on Sep 11, 2009 by kef

MC9S12XDT256

P&E USB ML12 and True-Time debugger

 

I need to determine at run-time if my debugger is in control. I have an external watchdog that resets the CPU when it hits a breakpoint but the external watchdog can be disabled during initialization if the firmware can reliably determine when it is in debug mode. So, I need to determine if the debuger MIGHT stop the CPU later and disable the watchdog in my powerup code.

 

I have a solution that reads the DBGC1 register to determine the mode. I found that this register is either 0x00 when not debugging or 0xB0 or 0xBC when the debugger is connected. I have read the ref manual on the Debug module but I'm not sure I understand it very well. It doesn't look like I can rely on more than three bits to be in a known state in all debug modes. So right now this is my solution:

 

if((DBGC1 & 0xB0) == 0xB0)

 

Since the reliability of this watchdog is critical, I need to make sure that the solution is foolproof.

 

If anyone can confirm my findings or suggest a better solution to my problem, I would appreciate it.

Outcomes