Daniel Rogers

8-16: Bit declaration / usage problem

Discussion created by Daniel Rogers on Dec 17, 2006
Latest reply on Dec 19, 2006 by Daniel Rogers
I have a structure of 80 odd flags declared as single bits in the same struct.
typedef struct
 unsigned bBkLightTimerReset:1;
 unsigned bAllCupReq:1;
 unsigned bTestAll:1;
 unsigned bTestSingleLane:1;
 unsigned bTestSingleDrop:1;
 unsigned bTestRotation:1;
I then decleared it
FLAGS Flags;
I have a interrupt that calles a routine that sets one flag and clears an other.
The next line after that routine tests the two flags.
If I check the status of these two flags after they are set/cleared they are as I set them. When i get back to the line that tests the two flags they are inverted.
Remebering that the code is all inside an interupt therefore nothing else can affect the flags.
If I declear the struct with uchar ..... instead of unsigned .......:1 they flags all behave as they should. ie there status stays as I set them.
Is there a option I should be setting in the compiler setup or is there a problem with the compilers handling of bits decleared this way.

Message Edited by CrasyCat on 2007-04-13 11:23 AM