Log in

View Full Version : MPLAB Variable Simulator?


Chris_Elston
17-02-2004, 21:21
This is really the first time I've used this MPLAB software and the first time I've coded in C language. Normally I code in Ladder Logic, (Programming Logic Controllers), Visual Basic, or what ever proprietary language or mnemonic language of the week that might be in whatever servo controller I get my hands on. However I’ve notice a nice tool in MPLAB I'd like to know a bit more about.

When I program my C program offline, I see that I can use the MPLAB simulator much like a Visual Basic debugger. The problem is I can't see or figure out how to simulate variables to keep executing in my code. Example:

My offline debugging gets STUCK in a loop here:


/************************************************** *****************************
* FILE NAME: ifi_utilities.c
*
* DESCRIPTION:

snippppeddd a few lines of code…..........................................


/* Used when transmitting data serially. It waits for each byte to finish. */
void Wait4TXEmpty(void)
{
#ifndef _SIMULATOR
while (!TXINTF)
{
continue;
}
#endif
}


I need to be able to SIMULATE the variable !TXINTF so that I can get past this part of the code while performing a STEP function in the debugger. I am sure may other spots will be required to be simulated imputs also to get the loop area where the user code is executing. Is there anyway in MPLAB to setup this variables and many more to toggle or force values?

deltacoder1020
17-02-2004, 21:27
what you actually need to do is define the macro "_SIMULATOR" - hence the #ifndef lines around that particular loop. there are certain parts of the code that will get stuck without that macro defined. just go into the mplab project settings window and look for where you can define preprocessor macros, and add _SIMULATOR to the list.

Chris_Elston
17-02-2004, 21:37
I eye! Captain. Found it under Build Options. Well give that a whirrlly gig..

Mark McLeod
18-02-2004, 12:08
You'll also find yourself running into problems if you are using the internal timer interrupts. The easiest way around that is to add your own #ifdef _SIMULATOR around the timer initializations to turn the interrupts off for debugging.