On Sat, 9 Dec 2006 at 09:58 -0800, Robert Spanton <[email protected]> wrote:
I'm having trouble with mspgcc version 3.2.3 accessing a variable
that's been declared as volatile twice, when my code refers to it
only once. This is a problem because that variable happens to be
I2CIV, the value of which changes upon access.
I've attempted to create the smallest piece of code that still
generates this fault (or, at least, what I regard to be a fault).
volatile int test;
int main( void )
{
int i;
switch( test )
{
case 0: i = 1; break;
case 1: i = 2; break;
....
}
}
Note that the code is accessing the switch variable twice, in the cmp
instruction at 0xfc46 and in the mov instruction at 0xfc4c.
This is fairly problematic, since when I switch on the value of I2CIV
in my I2C interrupt function I miss a large number of interrupts!
I'm guessing you weren't optimizing your example code - what
happens if you create an example with -O2 and real side effects
since i is local in this case.