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

good code bad answer

my code is 110% correct; eg no errors and runs properly. see.

int _val;

int myfunc2(int val)
{
  _val = val;
   return _val;
};

int Bar(int val)
{
  return _val + val + 1;
};

void myfunc1(int val)
{
  _val += Bar(val);
};

etc
etc
etc

it doesnt give me the right answer sometime.

HEEEEEEEELLLLLLLPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPP

Parents
  • On the contrary - it is entirely pertinent!

    It is actually quite a common type of mistake - especially when using a "slow" CPU with a "fast" peripheral.

    And it is exactly the type of problem that can give the situation of the OP; viz, the code builds fine, works most of the time - but occasionally fails.

    It's even likely that the code would work fine in an instruction set simulator like the one in uVision.

Reply
  • On the contrary - it is entirely pertinent!

    It is actually quite a common type of mistake - especially when using a "slow" CPU with a "fast" peripheral.

    And it is exactly the type of problem that can give the situation of the OP; viz, the code builds fine, works most of the time - but occasionally fails.

    It's even likely that the code would work fine in an instruction set simulator like the one in uVision.

Children
No data