Hello, There is a problem with accessing bit fields in structs: It seems that whenever the first member of a struct is a bitfield consisting of more than 1 bit a subsequent bitfield in the same struct is accessed incorrectly (writing seems to work ok, but reading not). This is true for msp430-gcc 3.3.2 and 3.4.0. It does, however, work correctly for 3.2.3. I pasted in a simple application isolating the error.
Compiled under RedHat 9 with: msp430-gcc -Os -g -mmcu=msp430x149 -o app.elf app.c Regards, Jan Hauer //------------------- code snippet start ---------------------// typedef struct { unsigned int flag1: 4; unsigned int flag2: 1; } s1_t; typedef struct { volatile unsigned flag1: 4, flag2: 1; } __attribute__ ((packed)) s2_t; typedef struct { unsigned int flag1: 1; unsigned int flag2: 1; } s3_t; s1_t s1; s2_t s2; s3_t s3; int test; int main() { test = 0; s1.flag2= 1; s2.flag2 = 1; s3.flag2 = 1; if (s1.flag2 == 1) test += 1; else test += 2; if (s2.flag2 == 1) test += 10; else test += 20; if (s3.flag2 == 1) test += 100; else test += 200; // results // msp430-gcc 3.2.3: test = 111 // msp430-gcc 3.3.2: test = 122 // msp430-gcc 3.4.0: test = 122 } //----------------- code snippet end -------------------//