Go to Post I have never seen a coach with a better ability to yell with love. - IndySam [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 01-11-2003, 14:34
WizardOfAz's Avatar
WizardOfAz WizardOfAz is offline
Lead Mentor
AKA: Bill Bennett
FRC #1011 (CRUSH)
Team Role: Engineer
 
Join Date: Mar 2003
Rookie Year: 2002
Location: Tucson, AZ
Posts: 101
WizardOfAz will become famous soon enough
Send a message via AIM to WizardOfAz
using the MPLAB IDE MPLAB SIM simulator

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
  #2   Spotlight this post!  
Unread 03-11-2003, 01:24
Lloyd Burns Lloyd Burns is offline
Registered User
FRC #1246 (Agincourt Robotics)
Team Role: Engineer
 
Join Date: Jun 2001
Rookie Year: 1997
Location: Toronto
Posts: 292
Lloyd Burns is an unknown quantity at this point
Oh, the hours I've spent stepping through a program with software delays and serial I/O on PIC16F- and C-84's. If you use the special function register watch, you can watch a message get spelled out as it goes through the W reg, but it might be easier to branch to a halt at a known location when you get the expected result. This avoids string-sending simultions.

The other place where simulation produces Megatorrs of vacuum is on inputs - try to get the timing to coincide with what you want for your event ! The newer IDE works a little smoother than the first simulators (even the one for DOS ).
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:04.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi