On Tue, 4 Dec 2001 09:30:14 +1000, you wrote: >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; > >BitDataByte myData; > >myData.Value =3D 42; > >myData.Bits.Bit0 =3D 1; Could you then simplify the access to the bits by doing=20 #define modeflag myData.Bits.Bit0 modeflag=3D0; etc. ? Could you also simplify the above declaration by using=20 bit Bit0; instead of int Bit0:1; >Will get you started.. the ": 1" tells the compiler to allocate 1 bit to= the >element, but you can allocate any number. So you can have a 2 or 3 or 14= bit >number as you choose. more details should be in your local C language = book >:) > >Cheers, >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 Sean H. Breheny >> Sent: Tuesday, 4 December 2001 8:47 AM >> To: PICLIST@MITVMA.MIT.EDU >> Subject: Re: [pic]:Accessing a var as a byte or bits in C >> >> >> What is the syntax? I've been using C for 9 years (mostly on >> PCs but also >> on microcontrollers) and don't recall ever seeing it! >> >> Sean >> >> At 03:43 PM 12/3/01 -0500, you wrote: >> >Normal C has bitfields in it. Usually you use them in >> structs or unions. >> >Problem is you don't usually know which bit is assigned, so I prefer >> >assembly at that level of detail. >> >/\/\/\/*=3DMartin >> >> ---------------------------------------------------- >> Sign Up for NetZero Platinum Today >> Only $9.95 per month! >> http://my.netzero.net/s/signup?r=3Dplatinum&refcd=3DPT97 >> >> -- >> http://www.piclist.com hint: PICList Posts must start with ONE topic: >> [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads >> >> >> -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics