Has anyone ever seen an authoritative document on using debug functions in uVision3? It could be a powerful tool if I knew how to use it, but what little information I have come across is scattered across 2 hardcopy manuals, a bit more in the help file system, and smatterings in the Keil Knowledgebase. Here are clues, not documented anywhere, that I have discovered by trial and error: - If the last line of a .ini file containing function definitions does not end in a CR/LF, you get a "syntax error". - The "Breakpoint Set (BS), and "Go" (GO) commands may be executed from the command line, but not inside a function. - If you access program variables from the function, you must halt execution at a point in the program where they are all in scope before you load the function with an "include" command. Otherwise you get another "syntax error." - When you define and/or when you invoke a function, you must terminate its name with a pair of parentheses. When you "kill" the function, you must omit the parentheses. Otherwise, you get another one of those ubiquitous "syntax errors". - It could be that everything is a syntax error in this domain. The messages are that useful. :-} Perhaps if we all pool our insights, we will have a running start on a manual. ============================================================ Gary Lynch | To send mail, no$pam in domain name lynchg@no$pam.com | must be changed to stacoenergy.
You can work around the 3rd item by creating a function inside your target application, declare a bunch of automatics, and copy all globals of interest to one of the automatics before you hit the breakpoint from which you define your function:
int glob1, glob2; void main(void) { int lclMn1, lclMn2; uV3Break(lclMn1, lclMn2); } void uV3Break(int parm1, int parm2); int glbuV1, glbuV2; int dummy; glbuV1 = glob1; glbuV2 = glob2 dummy = 0; return; }
At this point: parm1, parm2, glbuV1, glbuV2 are all in scope and can be used by a user-defined function.
Here the statement "dummy = 1" gives me a place to set a breakpoint, from which to launch my command file.
exec("#define NO_OF_SAMPLES 12");
include dumpIoPorts.ini
DIR UFUNC
command. If your function does not appear in the list, it failed.
dumpIoPorts();
You may invoke it from inside a command file, too, but I haven't found that particularly useful.
KILL FUNC dumpIoPorts
before you can read the next version back in.
Note that in the definition and invocation of my function, I have adhered to strict C syntax for the function name, including parentheses that surround a parameter list (even if you use no parameters), and the terminating semi-colon. Note also that I DO NOT use the latter 2 elements with the KILL command. Try that and you run afoul of the infamous ....
<drum roll>
Aw, never mind. You know the routine by now.
and I recommend it over the manual methods.
============================================================ Gary Lynch | To send mail, no$pam in domain name lynchg@no$pam.com | must be changed to stacoenergy.