Hi all,
I'd like my code to be able to detect if it is running under the debugger, so I can print to the debug console (using the Trap #14 halt mechanism) if it is available. I'm wondering if there is a way to do this generically, without having to change the project files...
The only way I have managed to do this is to modify the debugger cfg file to modify a MCU register from its default value, such as:
; Debugger attached flag -- MCF_GPIO_PORTAN == 0
writemem.b 0x4010000A 0x00
And then I test for it in early boot:
// we read MCF_GPIO_PORTAN's initial value to determine if the debugger is attached
// N.B. this value must be set by the debugger's cfg file!
if (! MCF_GPIO_PORTAN) {
debugger_attached = 1;
} else {
// turn off pstclk to reduce emi
MCF_CLOCK_SYNCR |= MCF_CLOCK_SYNCR_DISCLK;
}
The problem with this is it requires the cfg file modification, which I'd like to not have to do.
Does anyone know of a better way to do this? Thanks!
-- Rich