Thanks for the reply, Dave
Unfortunately the code snippet below is not the "real" code, but a
quick throw-together to illustrate the problem I'm having.
In the real code, the variables are initialized with real data.
Either statically (for testing) or dynamically from a pre-defined
location in EEPROM.
ICC actually initializes the value to 0 automatically as part of the
compile process anyhow ...
I'm still having no luck trying to solve this problem - might try and
use a series of if-then-else handlers instead of the alternating
while loops ... hmmm ...
Thanks again for the reply.
Cheers,
Jon
--- In AVR-Chat@yahoogroups.com, "Dave Hylands" <dhylands@...> wrote:
>
> Hi,
>
> > Code that doesn't work:
> >
> > main ()
> > {
> > unsigned int val;
> > unsigned int otherval;
> >
> > val = 650;
> >
> > while (1)
> > {
> > while (otherval < val)
>
> otherval is currently uninitialized and will take on some random
value
> from the stack.
>
> > Code that DOES work:
> >
> > main ()
> > {
> > unsigned int otherval;
> >
> > while (1)
> > {
> > while (otherval < 650)
>
> otherval is still uninitialized. The fact that it works is pure luck
>
> --
> Dave Hylands
> Vancouver, BC, Canada
> http://www.DaveHylands.com/
>Message
Re: C Code weird behaviour help?
2007-01-28 by luthjej
Attachments
- No local attachments were found for this message.