From MPLAB 8.92 to MPLAB X 5.25: how do I programmatically halt the simulator now?

302 Views Asked by At

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.

1

There are 1 best solutions below

2
On

In MPLAB go to Project Properties. In Categories tree: select Simulator the Options for Simulator are now visible. Under Options categories select Warning Messages Break Options and press on Unlock button.

Let say that you wont that your simulations stops on Watchdog Timer reset event. Find on list W0004-CORE: Watchdog Timer has caused a Reset. and change Report option to Break. Press Apply button. Now the program simulation will stops on every Watchdog Timer reset event.

PS: I'm using MPLAB v5.35. For break at stack overflow use option W0012-CORE: Device Resets on stack overflow.