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.
Solved! Go to Solution.
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
}
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
}