Hello guys,
I am using semihosting on S32K144 for debugging (using printf statements) in my project. I observed that when the debugger is detached, code gets stuck at 'printf'.
I want to know how to check if the debugger is connected in-code, so that i can bypass/redirect the printf to some empty function when debugger is not connected.
Regards,
Prasanna
Hello prasanna.rawke@carnot.co.in,
The debugger writes to the ARM Debug system registers
Arm®v7-M Architecture Reference Manual | Arm®v7-M Architecture Reference Manual – Arm Developer
C1.6 Debug system registers
But as far as I know, when the debugger gets disconnected, none of them reflects that.
However, when the debugger is active, you can see it on the bus.
JTAG_TDI pin (PTC5) has a pullup enabled by default.
So, when the debugger is disconnected, PTC_PDIR[5] should read high constantly.
BR, Daniel
Hi Daniel, Thanks for the solution. It worked for evaluation kit, where it uses OpenSDA for debugging. I noticed that the status of this pin does not change while debugging via SWD protocol.
With SWD debugger, I am reading the DHCSR register to check if the debugger is connected. LSB indicates if the debug mode is ON or OFF.