Oops, yep, that's what I get for cutting and pasting PIC code :) When you do tricks like this, ALWAYS check that the compiler laid out the structure like you thought it did by looking at the size of the structure and watching what the program does in a debug memory window. Ash. --- Ashley Roll Digital Nemesis Pty Ltd www.digitalnemesis.com Mobile: +61 (0)417 705 718 > -----Original Message----- > From: pic microcontroller discussion list > [mailto:PICLIST@MITVMA.MIT.EDU]On Behalf Of Bob Ammerman > Sent: Tuesday, 4 December 2001 3:06 PM > To: PICLIST@MITVMA.MIT.EDU > Subject: Re: [pic]:Accessing a var as a byte or bits in C > > > Note that this is great, but according to ANSI sizeof(Bits) > == sizeof(int), > not sizeof(Bits) == sizeof(char). > > Also according to ANSI, int must be at least a 16-bit value. > > Bob Ammerman > RAm Systems > > ----- Original Message ----- > From: "Ashley Roll" > To: > Sent: Monday, December 03, 2001 3:30 PM > Subject: Re: [pic]:Accessing a var as a byte or bits in C > > > > Hi > > > > typedef union { > > struct { > > int Bit0 : 1; > > int Bit1 : 1; > > int Bit2 : 1; > > int Bit3 : 1; > > int Bit4 : 1; > > int Bit5 : 1; > > int Bit6 : 1; > > int Bit7 : 1; > > } Bits; > > unsigned char Value; > > } BitDataByte; > > > -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads