How can I detect if a debugger is attached to a Kinetis via SWD_CLK and SWD_DIO?

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

How can I detect if a debugger is attached to a Kinetis via SWD_CLK and SWD_DIO?

1,150 次查看
markminich
Contributor I

I want to determine at runtime if a debugger is attached, and disable/enable printf()'s based on that. (Yes, I understand that this alters the timing of things and thus an application's behavior.) How can I tell if a debugger is attached to the Kinetis's SWD_CLK or SWD_DIO pins? Though I'd expect it to not matter as far as the solution goes, I'm using P&E Multilink. My part is a MKL26Z128VFM4 (KL26 sub-family).

标签 (1)
0 项奖励
回复
1 回复

949 次查看
ZhangJennie
NXP TechSupport
NXP TechSupport

Hello Mark,

in debug mode,  we can detect clock on SWD_CLK pin. while in run mode there is not.

so one idea is to use a free GPIO connect SWD_CLK, set this GPIO as input. use this GPIO detect if SWD_CLK has clock. if yes, it's debug mode. otherwise, it's run mode.


Have a great day,
Zhang Jun

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 项奖励
回复