[Tinyos-help] AVR GCC compiler problems

Kevin Klues klueska at gmail.com
Wed Feb 27 12:27:11 PST 2008


> One more thing: Does C support coercion?

Yes C supports coercion, but the problem you have is that you are
really executing two statements in the assignment.  Coercion only
happens after the shift has occurred.  so first the compiler does
(number1 << 14), then it converts it to a 32 bit number to assign it
to number2.  You need the explicit cast to tell the compiler to first
convert number1 to 32 bits, then do the shift, then do the assignment.

> Do you use casting for all your 32-bit statements?

I don't know what you mean "for all my 32-bit statements".  Yes, if I
ever have a 16 bit number that I am shifting or multiplying by a
variable with a different precision then yes I use a cast.  Between
variables of the same type, no.  This is the standard way of doing
things in C.

> Another clue: The error happens only when there are few sentences betweens
> two (or more) calls to the routine. If I wait some time for the second call,
> it works fine. However, as you can see in the code, the routine doesn't need
> clock cycles to be called again.

You must have some sort of race condition somehwere that is causing
the eror somehow, otherwise I'm not sure what it might be.

Kevin


More information about the Tinyos-help mailing list