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

char variables not initializing correctly

I have a function in which I declare two variables as follows:

unsigned char voltage = 0;
unsigned char test = 0;

When I run the code in the debugger, these variables are initialized to random numbers. What is the problem?

Parents
  • "Okay - my next guess would be to suggest that they are possibly being over written by something else."

    I that's the case, you should be able to see it happening in the debugger: use the disassembler view, and you'll be able to see where your local variables are initialised. Step through the code at the assembler level, and see where it goes wrong.
    This should give you some more clues.

    Other possible causes could be:
    Errant pointers;
    Overlay problems (especially if you're using function pointers, or calling functions recursively);
    Stack problems.

Reply
  • "Okay - my next guess would be to suggest that they are possibly being over written by something else."

    I that's the case, you should be able to see it happening in the debugger: use the disassembler view, and you'll be able to see where your local variables are initialised. Step through the code at the assembler level, and see where it goes wrong.
    This should give you some more clues.

    Other possible causes could be:
    Errant pointers;
    Overlay problems (especially if you're using function pointers, or calling functions recursively);
    Stack problems.

Children
No data