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?

Parents
  • 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

Reply
  • 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

Children
No data