2

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.

Regus Pregus
  • 560
  • 3
  • 12

1 Answers1

0

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.

GJ.
  • 10,810
  • 2
  • 45
  • 62
  • Thank you for your response! As I have mentioned in the original message, I did exactly that, and it does not help. Even if I set all options to "break" (including W0012-CORE), it still does not break on "call $". In fact, it does not even report stack overflow in the console output. So it seems like the stack overflow never gets detected altogether. This is in 5.25. My hope now is that it is a bug in 5.25 (since you are reporting that it works in 5.35). I will try 5.45, the latest version and will report. – Regus Pregus Mar 06 '21 at 23:45
  • Do not set all options to break, because at me this doesn't work! And do not forget to press "Apply" button when you change the option! – GJ. Mar 06 '21 at 23:54