I’ve seen very little written about the MPLAB SIM. I’m starting to learn how to use it, but maybe others have already gotten much farther. This thread is dedicated to people sharing hints and kinks, and helping solve problems and answer questions, about the MPLAB SIM.
For starters, there are a few macros that can be defined that affect code execution. One is particularly useful for running in the simulator: _SIMULATOR. Without this, you have two problems with the “default” code:
(1) statusflag.NEW_SPI_DATA will never be 1, so your user code in Process_Data_From_Master_uP will never be called by the loop in main.c.
(2) TXINTF will never be 1 so Wait4TXEmpty will loop forever causing your program to hang the first time it tries to print anything.
To set this macro, click Project->Build Options->Project, click the MPLAB C18 tab, click the ADD button to the right of macro definitions, type _SIMULATOR, OK, OK.
There is a hazard here - if you leave this macro enabled, your code WILL NOT RUN successfully on a real controller. You want to only use this setting for running in the SIM. You have to take the macro out, then rebuild before download the code to a controller.
The other macros I see used in the code are:
UNCHANGEABLE_DEFINITION_AREA
_NO_BOOTLOADER
_SNOOP_ON_COM1
_FRC_BOARD
Anybody figured out when these are useful?
Finally, it would be real handy to be able to view output of printf and other print calls in the simulator. Anybody figured out a way?
You can sort of do it with a watch on a string in a fixed location, and have the print routines put their output there. A better way would be better…
Bill