> > 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; My declaration isn't _the_ port, it's a variable called Port. I grab the state of a port at a single instant in time so the code immediately above the 'if' statement is PortB.Byte = PORTB; There are a pile of bit tests that get done at each sampling time and if a bit gets tested as a 0 and then gets tested again as a 1, the logic flow goes all up the creek. The PORTA = 0x55 was just as an example. This code gets used on several products that use different chips and pin assignments. This is a fairly efficient and tidy way of moving bits around so that they can be manipulated individually and/or collectively as bytes and mask values. Steve. ========================================== Steve Baldwin Electronic Product Design TLA Microsystems Ltd Microcontroller Specialists PO Box 15-680, New Lynn http://www.tla.co.nz Auckland, New Zealand ph +64 9 820-2221 email: steve@tla.co.nz fax +64 9 820-1929 ========================================= -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.