1.2 Using Simulator in a Debugging Session

When a debugging session with the simulator is started, a simulator model of the selected device is loaded and programmed with the user's application. After the application is loaded into the application memory, a Power-on Reset (POR) is applied to the model. Hence, the simulator will start at the reset vector with the POR reset flag set. If the user used “Start Debugging/Continue (F5)” to start the debug session, the simulator model would now be running and start executing the application. If the user used “Start Debugging and Break (Alt+F5)”, the simulator would start running until it reached the start of the main() function and then do a break.

The Reset button in Microchip Studio applies a POR to the simulator. The content of flash and EEPROM are not lost during Power-on Reset (POR). When doing a reset in Microchip Studio, the execution will normally break at the start of the main() function. By switching to the disassembly view before performing the reset, the execution will halt at the reset vector. If Watchdog is programmed to generate a reset, it can be caught through setting a breakpoint at the reset vector and let the simulator run.

There is no way to attach to a running simulator, or detach/disconnect from it and keep it running in the background. Like in the programming dialog, the simulated device ceases to exist when the user stops debugging. This is a restriction that may be lifted in future versions of Microchip Studio.

Because the simulator is a software model, it is not limited by the OCD system on the device, and has certain capabilities that the hardware tools do not share:

  • Unlimited numbers of breakpoints regardless of device and OCD system limitations

  • Set and delete breakpoints while the target is running

  • Can debug and supports trace on all devices, even those that lack an OCD system

  • Access to locations that can not be reached by the OCD system

  • Provide features that have no counterpart in hardware, for instance, a cycle counter

  • Unlike real hardware, the simulator allows flash and EEPROM contents to be changed directly using the Microchip Studio memory view

  • Can simulate devices that do not exist yet (early support before samples are available)