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

Debug problem in ver. 7.04

I try to debug simple code

static void com_isr (void) interrupt 4 using 1 {
unsigned char data c;
/*- Received data interrupt. -*/
  if (RI) {
    c = SBUF;
    RI = 0;
    ...
    ...
  }
}
and local variable c do not have a value of SBUF and I don't see any local variables in the "Locals" page of "Watch" window.
Can anybody help?

  • I think the debugger assumes that 'C' is the Carry flag - there was a thread about this recently.

    Try renaming your local variable (you're not writing BASIC now!)

  • I rename it to any symbols with the same result.

  • The carry flag is normally CY and I know that I have used a variable name of c without any problems.

    I suspect the optimiser. Look at the assembly code (in the xxx.cod listing), I expect that you will find that c is assigned to a register. This seems to give the debugger some problems when it tries to find a value.

    A couple of ideas: Try defining c as a static or volatile or try turning the level of optimisation right down.

  • Thank You, Graham.
    With c defined as static debuger work fine.
    But what about local variables in the "Locals" page of "Watch" window? I don't see them.

  • If you don't ever do anything with 'c' and since 'c' is defined as a local automatic, then the compiler correctly reads SBUF and discards the results.

    You should know this, this is how optimizing compilers work. You can either: 1) use the value in 'c' for something, like stuff it into an array, 2) declare it static (as you have), or 3) declare it volatile.

    What good is receiving a char if it will never be used? If you just want to discard Rx data then the statement:

    SBUF;
    all by itself will read SBUF and discard the results.

    --
    - Mark