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
  • Just a quick thought - where are you initialising them?

    If it is just in the function you've written,
    then they would in theory only exist while the function was being executed, but not while any other piece of the code was in use.

    To check this out - you could try declaring the variables globally, and see if it makes a difference.

    What do you reckon?


    Yours,


    Richard.

Reply
  • Just a quick thought - where are you initialising them?

    If it is just in the function you've written,
    then they would in theory only exist while the function was being executed, but not while any other piece of the code was in use.

    To check this out - you could try declaring the variables globally, and see if it makes a difference.

    What do you reckon?


    Yours,


    Richard.

Children
More questions in this forum