This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430 detect attached debugger from the code.



I would like to detect whether the debugger is attached so that in my error handler I will immediately break into the debugger, but in field units, the CPU will reset. Is there any way to detect if the debugger is attached?

void handle_error(){

if( debugger_attached ) BREAKPOINT;

RESET_CPU;

}

  • I can't see any register which indicates if a debugger is attached.

    However, once the debugger is attached can't you just set a breakpoint on the handle_error function, so that will stop at the breakpoint rather than reset?

  • As an alternative, you can do the following:

    void handle_error(void) {

    REST_CPU; /* *** Put a BREAK-POINT on this line *** */

    }

    If the debugger is not attached, the BREAK-POINT will be ignored and RESET_CUP() will be executed.

  • The CPU cannot detect whether it is under debugger control or not.

    On 5x devices, the debugger can send a JTAG message and the CPU will get an NMI. But whether sending JTAG messages is supported depends on teh debugger too.
    Another, also debugger-dependent solution is lettign the debugger change a global variable to '1' that is initialized to '0' an dnever touched,. The code then can check whether it has turned to '1' as sign of athe presence of a debugger.

    However, if you just want to stop at a certain point when the debugger is attached, then a simple breakpoint is sufficient, as already proposed.

**Attention** This is a public forum