MPLab seems to have a very powerful debugger and simulator for our chipset but, even with the tutorial, I can’t seem to get it to work. The key here is that when I go through the tutorial, it eventually asks me to put in some assembly code and I have no idea where this comes from. When I run the bot code with the assembly, it seems like it only runs the assembly part - at least I can only watch and step through the assembly code.
If someone could give me just a little bit of help, I think I understand the rest enough to write a small tutorial specific for our new chipset - something that I think will greatly benefit anyone programming this year.
To use MPLAB SIM with the EDUCode default program open the project.
Under Project -> Build Options… -> Project
The pop-up has a tab for the MPLAB C18 compiler. At the bottom of this page are the compiler options
-Oa -Os etc
To the bottom line add
and click the radio button.
_SIMULATOR is used as a flag within the code to skip over a transmit to the Master uP. If it’s not there the SIM will wait forever for the non-existent Master uP to talk to it. You can look for it in the code.
The MPLAB SIM buttons get added to the menu bar by selecting MPLAB SIM from the Debugger pull-down.
Open one of the source files like user_routines.c and double click on a line you know will get executed. This sets a breakpoint. Then hit the run button. The SIM will stop with an arrow pointing to the line with the breakpoint and you can single step from here.
Remember to remove the -D_SIMULATOR from the options before using the EDU controller.