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

How can I use a global variable in the Interrupt routine?

The variable is defined in *.h:

static unsigned char cPwLe[3] = {0};

Its value is changed in the Main():
cPwLe[cCh] = Power_Level(cP[cCh]);  //Here  value is right

Its value is transfered to T0 Interrutpt service routine:
cPower = cPwLe[cCh]; //Here value is  always 0

How can I correct the errors?
Thanks all!

Parents
  • Can you tell why?

    No. Nor can anybody else, from what you wrote. You're not giving anywhere nearly enough information for that.

    Just a MOD caculating result in the mistake:

    In what mistake?

    When be corrected to if (){} and add statement

    There's nothing to be corrected about what you wrote --- ripped completely out of context as it is, it's impossible for anyone not sitting on your chair to find out what "correct" might possibly mean, for this snippet of code.

Reply
  • Can you tell why?

    No. Nor can anybody else, from what you wrote. You're not giving anywhere nearly enough information for that.

    Just a MOD caculating result in the mistake:

    In what mistake?

    When be corrected to if (){} and add statement

    There's nothing to be corrected about what you wrote --- ripped completely out of context as it is, it's impossible for anyone not sitting on your chair to find out what "correct" might possibly mean, for this snippet of code.

Children