I wrote some test code in PIC assembly language that I have no intention to run on the actual PIC MCU, rather it is meant to generate the trace files so that they can be analyzed later with a separate tool. So, I needed a way to permanently halt the simulator in specific code points without manually setting the breakpoints there. This way I could terminate trace collection from code.
Back in the MPLAB 8.92 I used this simple trick to accomplish that: "call $" command. This instruction simply calls itself, quickly overflowing the stack and in MPLAB 8.92 this was halting the simulator with CORE-E0001 message. Mission accomplished!
However, when I migrated to MPLAB X 5.25, I have discovered that the simulator does not halt anymore using this trick. It does not halt even if I go to the project settings and specify that simulator should break on all types of warning messages.
So, what am I doing wrong? What it the best working way to halt the simulator with an MCU code in MPLAB X? Please do not suggest using an explicit breakpoint, this is just not practicable, I would literally need to set hundreds of breakpoints in tens of projects.
In MPLAB go to
Project Properties
. InCategories
tree: selectSimulator
theOptions for Simulator
are now visible. UnderOptions categories
selectWarning Messages Break Options
and press onUnlock
button.Let say that you wont that your simulations stops on
Watchdog Timer
reset event. Find on listW0004-CORE: Watchdog Timer has caused a Reset.
and changeReport
option toBreak
. PressApply
button. Now the program simulation will stops on everyWatchdog Timer
reset event.PS: I'm using MPLAB v5.35. For break at stack overflow use option
W0012-CORE: Device Resets on stack overflow.