Hi,
Debug launches in the simulator even when that command is not in the code!
That's rather the wrong way around. The Simulator
IS a "Debug Window". The Simulator is basically just an "Array of Numbers" that are updated by reading a sequence of instructions (i.e. the program) in the Editor. IF it
didn't show the "numbers" to a User, then there wouldn't be much point in using it!
In practice, there are additional Wizards and device Emulations included in the Editor/Simulator, but that's just Rev. Ed. being helpful to Students (or their teachers).
The DEBUG command is intended to give a similar "User Experience" when using a "Real" PICaxe chip and to be honest it does that quite well. Potentially very useful for commands that the Simulator doesn't support (e.g. PEEK/POKESFR), or incorrectly (there are just a few "bugs", particularly with PE5), or where the Simulator is too slow. But the latter is the reason that I don't use it (i.e. never include it in any of
my programs or snippets that I post to the forum). To be fair, the
Command Syntax is completely honest in saying:
"Note that the debug command uploads a large amount of data and so significantly slows down any program loop. To display user defined debugging messages use the sertxd command instead."
The problem is that some Users may never read that, or not appreciate that their program is "Time Critical", or "forget" that they ever read it! Therefore, the "safe" recommendation is to NOT use it.
As an aside, one of the reasons that some programmers dislike the GOTO command and prefer "Structured Programming" is that if you wrote a program:
DO : READADC c.1 , b0 : DEBUG : LOOP then the Editor could issue a "WARNING - Debug will slow down the program", but if the program has a
GOTO main buried somewhere in it, the Editor has no way of knowing if there is a practical issue or not. However, people generally dislike "warnings", and in that particular example the DEBUG actually might be an advantage, because it will slow the screen updates down to about 6 per second. Replace that DEBUG with a
SERTXD (#b0 , " ") and the Terminal screen will fill up so fast that you won't be able to see what's happening. However, it will give an idea how fast even a PICaxe can work.
Cheers, Alan.