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

Problem passing variable to function in ISR

So, I have a problem sending a value to a function at different parts of my code. Here is my code:

void LongRightShift(unsigned char NumBitsShift)
{
// My Code Here
     NumBitsShift = NumBitsShift; // So you can place a breakpoint here and read NumBitsShift
}

Now, when I call

LongRightShift(2);

in the main part of my program, NumBitsShift = 2. When I call it in the Decimator2_ISR, NumBitsShift = 1;

Does this have to do with the way I'm passing it or is there a conflict with running other functions in an ISR?

Any help you can give me would be appreciated. Thanks!

Parents
  • One last thing I should note, the NumOutSamples and Pressure1 variables are being stored as global variables and I have them in my VARS.C file as:

    signed short idata Pressure1 = 0;
    unsigned char NumOutSamples = 0;
    

    Unfortunately, that means the code you showed so far has esentially no relation any more to the code you actually used. That makes it all but impossible to help you meaningfully.

    You've not only messed up the type of your key variable, Pressure1, from short to unsigned char, but also changed its storage duration (from static to automatic) and linkage (from function-internal to global). In short, you kept nothing but the name intact.

    If you have problems with some code, you really have to show that actual code, or at least a reduction of it that actually exhibits all the problems you have.

Reply
  • One last thing I should note, the NumOutSamples and Pressure1 variables are being stored as global variables and I have them in my VARS.C file as:

    signed short idata Pressure1 = 0;
    unsigned char NumOutSamples = 0;
    

    Unfortunately, that means the code you showed so far has esentially no relation any more to the code you actually used. That makes it all but impossible to help you meaningfully.

    You've not only messed up the type of your key variable, Pressure1, from short to unsigned char, but also changed its storage duration (from static to automatic) and linkage (from function-internal to global). In short, you kept nothing but the name intact.

    If you have problems with some code, you really have to show that actual code, or at least a reduction of it that actually exhibits all the problems you have.

Children
No data