We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
My Client has uVision2 v2.07. I want to write a uVision2 Debugger User Function which will run to a breakpoint and then display program data values. eg: FUNC void test ( void ) { exec( "G" ); printf( "%02X\n", myVar ); } This should GO to a previously-defined breakpoint, then display the value of myVar. myVar is a 'static' local variable inside a function; the breakpoint is inside the same function. Unfortunately, the *wrong* value of myVar is displayed - usually the value from *before* the GO!!! The same problem arises if the User Debug Function tries to examine values, or use 'exec' to display values via EVAL, etc. Does anyone else have this problem? Does anyone know how to fix it? Obviously this renders the uVision2 Debugger User Functions virtually useless for automatic testing if the values displayed cannot be relied upon!
Set a breakpoint on the instruction where you want to print the value. Use the Debug Menu to open the Breakpoints... Dialog. Add the printf( "%02X\n", myVar ) as the command for the breakpoint you just added. Now, whenever you reach that breakpoint, the debugger will automatically print the value of myVar. Keil Support
But why doesn't the User Function print the correct values? Are you saying that this is a real bug/limitation in User Functions? I quote from the uVision2 manual, "You may create functions that ... log memory contents to a file ..." I am trying to develop some automatic test harnesses using uVision2 User Functions. Therefore the User Functions need access to the program variables to test for Pass/Fail conditions. This is impossible if the values read by User Functions are incorrect!
The problem with the FUNC is that it does not DELAY and WAIT for the break point.
FUNC void test ( void ) { exec( "G" ); printf( "%02X\n", myVar ); }
Ah ha! That figures. The next question, of course, is *how* to make the FUNC wait for the breakpoint? Obviously, to write an automatic test harness, it needs to be able to setup preconditions, run to the required point, then test for pass/fail result.
There is no way to make a FUNC in the deubgger "wait" for a breakpoint. If you need to write a debugger function that waits for a while, take a look at the SIGNAL functions. Why do you need to have a FUNC that does this...
FUNC void test ( void ) { exec( "G" ); /*** WAIT FOR THE BREAKPOINT ***/ printf( "%02X\n", myVar ); }
FUNC void bp_1 ( void ) { /*** Execute for Breakpoint #1 ***/ printf( "%02X\n", myVar ); /*** Do other useful stuff here ***/ }
FUNC void bp_2 ( void ) { /*** Execute for Breakpoint #2 ***/ printf( "%02X\n", yourVar ); /*** Do other useful stuff here ***/ }