8 years ago.  This question has been closed. Reason: Off Topic

[SOLVED] bitfields not ordered right

I defined the next struct: typedef struct { unsigned bias:1; Bias generator on/off unsigned ref:1; Reference on/off unsigned dform:1; Data Format unsigned ub:1; Unipolar/Bipolar unsigned byteord:1; byte order unsigned bitord:1; bit order unsigned sdl:1; Serial Data Line SDIO/SDO unsigned dd:1; Data ready / Dsync unsigned mode:3; operating mode unsigned pga:3; Programmable Gain Amplifier unsigned ch:2; Channel unsigned turbo:3; Turbo Mode unsigned decrat:13; Decimation Ratio 19-8000 } CMRBit;

typedef union { CMRBit CommandBit; unsigned long CommandLong; } CMR;

When I R/W data as long it works correctly, but when I use CommandBit.bitfield it seems it ordered not in the right bit orders. For example mode field is handled in the second byte first bits. What can cause this issues?