9.2.13 __debug_break Builtin
A builtin function that triggers a software breakpoint for debug builds.
Include
<xc.h>
Prototype
void __debug_break(void);
Remarks
This is an inbuilt function that is expanded by the code generator for debug builds, but is ignore for production builds. When called, this routine unconditionally triggers a software breakpoint when the code is executed using a debugger.
The software breakpoint code is only generated for mid-range and PIC18 devices. Baseline devices do not support software breakpoints in this way, and the builtin will be ignored if used with these devices.
Example
#include <xc.h>
static i2c1_fsm_states_t I2C1_DO_BUS_COLLISION(void)
{
// Clear bus collision status flag
I2C1_MasterClearIrq();
I2C1_Status.error = I2C1_FAIL;
switch (I2C1_Status.callbackTable[I2C1_WRITE_COLLISION](I2C1_Status.callbackPayload[I2C1_WRITE_COLLISION])) {
case I2C1_RESTART_READ:
return I2C1_DO_SEND_RESTART_READ();
case I2C1_RESTART_WRITE:
__debug_break(); /* break when debugging only */
return I2C1_DO_SEND_RESTART_WRITE();
default:
__builtin_software_breakpoint(); /* unconditional break */
return I2C1_DO_RESET();
}
}