2020-11-18 02:17 AM
How could I in code sense that something is connected to the JTAG/SWD connector?
Solved! Go to Solution.
2020-11-18 02:55 AM
Practically, like this on Cortex M7:
bool is_debugger_enabled()
{
// NOTE: After disconnecting debugger, do power cycle because
// software reset does not seem to clear DHCSR.C_DEBUGEN!
// DHCSR and debugger behavior are described in ARM v7-M Architecture Reference Manual
return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk); // bit 0: DHCSR.C_DEBUGEN
}
2020-11-18 02:55 AM
Practically, like this on Cortex M7:
bool is_debugger_enabled()
{
// NOTE: After disconnecting debugger, do power cycle because
// software reset does not seem to clear DHCSR.C_DEBUGEN!
// DHCSR and debugger behavior are described in ARM v7-M Architecture Reference Manual
return (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk); // bit 0: DHCSR.C_DEBUGEN
}