This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

uVision2 User Functions get wrong values

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!


Parents Reply Children
  • 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 );
    }

    When assigning the printf call to the breakpoint does EXACTLY what it appears you are trying to do?

    If you need to do more than just print a value, you can create a separate FUNC for each breakpoint. For example:

    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 ***/
    }
    

    Then, when you define each breakpoint, you can call the bp_1 () and bp_2 () functions.

    Keil Support