Detecting debug mode at run-time

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Detecting debug mode at run-time

Jump to solution
1,318 Views
dwhite
Contributor I

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.

Labels (1)
0 Kudos
1 Solution
303 Views
kef
Specialist I

Unless you are using hotplug debugging, almost every debug session happens in special single chip mode. To distinct special from normal mode, you can use MODE register MODC bit.

 

if( MODE & MODE_MODC_MASK )

{

    //normal mode detected, BKGD pin wasn't pulled low on reset

}

 

View solution in original post

0 Kudos
1 Reply
304 Views
kef
Specialist I

Unless you are using hotplug debugging, almost every debug session happens in special single chip mode. To distinct special from normal mode, you can use MODE register MODC bit.

 

if( MODE & MODE_MODC_MASK )

{

    //normal mode detected, BKGD pin wasn't pulled low on reset

}

 

0 Kudos