Detecting debug mode at run-time

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Detecting debug mode at run-time

跳至解决方案
1,856 次查看
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.

标签 (1)
0 项奖励
回复
1 解答
841 次查看
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 项奖励
回复
1 回复
842 次查看
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 项奖励
回复