I am having some problem to pass parameter into subroutine.
I have defined:
BOOLEAN CRC_Message_Verify(UINT8 nbyte);
in my program, I have this line:
crc_ok = CRC_Message_Verify(SpiLoadIndex);
in which, SpiLoadIndex is defined as UINT8 xdata type,
when I single step debugging, before calling CRC_Message_Verify function, SpiLoadIndex = 5, and inside the subroutine, nbyte = 95. How come nbyte is totally different? Any ideas?
Is the variable wrong or the debugger just reports it wrong? Beside limitations of the debugger this could be a limitation of the optimizer. The variable may be used directly and not exist where it is placed. Or, the location may be shared. This means it can be over written to save space.
I will turn off optimizer and run some more test tomorrow. The bottom line is that the CRC result is not correct. This subroutine has been verified in other test program.
Last week, I even had problem with assigning variable in the same ISR routine, I had " A = B; " and after executing that line, value stored in A and B are not same. I have to use static to define them to make the equation right. Now I am wondering if these are related somehow.
this may be a pure coincidence, but have you noticed that 5 = 101 and 95 = 101 1111 ? did you check your assembly code? are you sure there are no implicit casts involved in the call...?