avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] BUG? Comparing of words error.


From: Graham Davies
Subject: Re: [avr-gcc-list] BUG? Comparing of words error.
Date: Wed, 18 Jan 2006 15:03:46 -0500

Flemming Steffensen  wrote: "Any idear what might be at play here?"

Sure.  The "bug" is that you have your main thread of execution and an interrupt sharing a variable with no access synchronization whatsoever.  If you just want to fix it, turn off interrupts while you're testing the value of RotCount.  If you want to understand it, you'll have to do what you haven't bothered to do yet, which is to look at the assembly output.  You'll find that the comparison is done in two steps, one for the high byte and one for the low byte.  Consider what happens when the interrupt fires in between these two steps and the first part of the comparison is done with the value before the increment and the second part is done after the increment.

Graham.
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]