Well, I use the union for ease of saving config bits to an E2PROM, saving those bits as whole bytes (chars). Francisco Gerhard Fiedler wrote: >>I use this in HiTech C >> >>typedef struct Port_s >>{ >> unsigned bit0 :1; >> unsigned bit1 :1; >> unsigned bit2 :1; >> unsigned bit3 :1; >> unsigned bit4 :1; >> unsigned bit5 :1; >> unsigned bit6 :1; >> unsigned bit7 :1; >>} Port_t; >> >>union >>{ unsigned char Byte; >> Port_t Bits; } PortA, PortB, PortC; >> >>and use it like this >> >>if (!PortB.Bits.bit5) >> PortA.Byte = 0xAA; >> >> > >I use something similar on occasion, but usually not for the ports. What is >the advantage of this union/bitfield over the Hi-Tech standard header >declarations, like > > if( !RB5) PORTA = 0xaa; > >? > >(Of course I usually wouldn't use RB5 in such a context, but rather a >meaningful name that gets associated with RB5 in a header file. But the >question remains the same.) > >-- >http://www.piclist.com hint: The PICList is archived three different >ways. See http://www.piclist.com/#archives for details. > >. > > > -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.