Debugging Details

The figure below illustrates the MPLAB® REAL ICE™ in-circuit emulator system when it is ready for debugging. See Requirements for Debugging and Sequence of Operations Leading to Debugging for more information.

Figure: Emulator and Target Ready for Debug

EmulatorReadyForDebug.jpg

The operation of a basic debug feature, a breakpoint, is shown below as an example of debug flow.


1

Set Breakpoint

Typically, in order to find out if an application program will run correctly, a breakpoint is set early in the program code. When a breakpoint is set from the user interface of MPLAB X IDE, the address of the breakpoint is stored in the special internal debug registers of the target device. Commands on PGC and PGD communicate directly to these registers to set the breakpoint address.

2

Run to Breakpoint

Next, the Debug > Debug Project function is usually selected in MPLAB X IDE. The emulator then tells the debug executive to run. The target starts from the Reset vector and executes until the Program Counter reaches the breakpoint address that was stored previously in the internal debug registers.

3

Debug Information on Halt

After the instruction at the breakpoint address is executed, the in-circuit debug mechanism of the target device “fires” and transfers control to the debug executive (much like an interrupt) and the user’s application is effectively halted. The emulator communicates with the debug executive via PGC and PGD, gets the breakpoint status information and sends it back to MPLAB X IDE. MPLAB X IDE then sends a series of queries to the emulator to get information about the target device, such as file register contents and the state of the CPU. These queries are ultimately performed by the debug executive.

The debug executive runs just like an application in program memory. It uses some locations on the stack for its temporary variables. If the device does not run, for whatever reason, such as no oscillator, a faulty power supply connection, shorts on the target board, etc., then the debug executive cannot communicate to the MPLAB REAL ICE in-circuit emulator and MPLAB X IDE will issue an error message.

4

Debug Information on Pause

Another way to stop execution is to select Debug > Pause. This toggles the PGC and PGD lines so that the in-circuit debug mechanism of the target device switches execution from the user’s code in program memory to the debug executive. Again, the target application program is effectively halted, and MPLAB X IDE uses the emulator communications with the debug executive to interrogate the state of the target device.

© 2017 Microchip Technology, Inc.
Information contained on this site regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyer's risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.