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
  • or is there a conflict with running other functions in an ISR?

    Yes, there is a conflict with running the same function from both the main code and an ISR. There is also a conflict with calling a function from any other one (including an ISR) that's running off a different register bank.

    If you need more help than that, you'll have to show more of your actual source code. Try to find the smallest possible example source that still shows the problem. And don't be to ashamed if halfway through this reduction process you have one of those "DOH! What was I tinking?" moments --- that's happened to everyone.

Reply
  • or is there a conflict with running other functions in an ISR?

    Yes, there is a conflict with running the same function from both the main code and an ISR. There is also a conflict with calling a function from any other one (including an ISR) that's running off a different register bank.

    If you need more help than that, you'll have to show more of your actual source code. Try to find the smallest possible example source that still shows the problem. And don't be to ashamed if halfway through this reduction process you have one of those "DOH! What was I tinking?" moments --- that's happened to everyone.

Children
More questions in this forum