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

Local Watch Window variables have wrong values...

While using the uV2 dscope debugger (in bootstrap loader mode) on my C167 board, the variables in my local watch window seemed to be working just fine, for a while, and then one of the local var's didn't seem to work anymore. For example, in the below code snippet, the local var 'i' always shows that it has the value of '1' in the watch window, no matter what the value of 'x' is displayed as, as I step past the code that assigns the value of 'x' to 'i'; and as the code is stepped through the ++i statement. Anyone know why this might be, and how I can fix it?

// U1 is a 16-bit latch clocked by CS4-
// U1 inputs are connected to the uC data bus
#define U1 HVAR(unsigned int 0x400000)
void foo(unsigned int x){
    unsigned int i;
    i = x;
    while(i){
        U1=i++;
    }
}

The while(i) loop does execute the expected number of times (based on the value of 'x' passed to the function).

I'm stumped...!

Parents
  • YIKES...!

    As I change the declaration of 'i' back & forth between

    unsigned int i;
    and
    static unsigned int i;
    (for the prior code example) the values displayed for 'i' in the local watch window change back & forth between incorrect and correct! BIZARRE!!! Anyone have a clue for why this is happening...? The bottom line seems to be that the local var's are only correctly updated & displayed properly when the local var is declared to be static! When the local var 'i' is NOT declared to be static, the value for it (in the local watch window) remains constant as the loop (that's changing it) executes!

    Confuzed...
    Dave.

Reply
  • YIKES...!

    As I change the declaration of 'i' back & forth between

    unsigned int i;
    and
    static unsigned int i;
    (for the prior code example) the values displayed for 'i' in the local watch window change back & forth between incorrect and correct! BIZARRE!!! Anyone have a clue for why this is happening...? The bottom line seems to be that the local var's are only correctly updated & displayed properly when the local var is declared to be static! When the local var 'i' is NOT declared to be static, the value for it (in the local watch window) remains constant as the loop (that's changing it) executes!

    Confuzed...
    Dave.

Children
No data