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
  • I'm afraid there's still some clarity that needs to be increased:

    Pressure1 is actually an unsigned SHORT (it was the end of the day and I looked right past this. It's originally in my VARS.C file so I had moved it over here and, apparently, posted it incorrectly).
    [...]
    when AveragedPressureOut = 500 (0x01F4) and Pressure1 = 550 (0x0226) (both are signed shorts)

    Not only did you contradict yourself there, but that bit of information you appear confused about is actually crucial to the issue at hand. The problem is that if even one of those variables actually is unsigned, in C51, then so is the resulting '50' you're comparing with the signed number -410. At that point you would enter the realm of comparisons between values of different signedness. You don't want to go there.

Reply
  • I'm afraid there's still some clarity that needs to be increased:

    Pressure1 is actually an unsigned SHORT (it was the end of the day and I looked right past this. It's originally in my VARS.C file so I had moved it over here and, apparently, posted it incorrectly).
    [...]
    when AveragedPressureOut = 500 (0x01F4) and Pressure1 = 550 (0x0226) (both are signed shorts)

    Not only did you contradict yourself there, but that bit of information you appear confused about is actually crucial to the issue at hand. The problem is that if even one of those variables actually is unsigned, in C51, then so is the resulting '50' you're comparing with the signed number -410. At that point you would enter the realm of comparisons between values of different signedness. You don't want to go there.

Children
No data