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!
void AverageOutput(void) { unsigned char tempvar = 0; unsigned char NumOutSamples = 0; unsigned char Pressure1 = 500; if(Pressure1<600) { NumOutSamples = 0; AveragedPressureOut=Pressure1; } else { //More code here } tempvar+=1; // Place breakpoint on this line }
That code does nothing, the Optimizer can remove it since it will not change the operation of the code. If tempvar was static it may keep it. it is was a volatile and declared out side the function it would be forced to keep it.
Did you noticed this ?
unsigned char Pressure1 = 500; if(Pressure1<600)
What is the maximum number that unsigned char in C51 can hold?