--------- > From: FrankT > To: PICLIST@MITVMA.MIT.EDU > Subject: 2 bytes into unsigned long > Date: Monday, 21 April 1997 22:16 > > Via I2c I receive 2 bytes HighByte and LowByte. > > What is the fastest way (with MPLABC) to convert them into a unsigned long > variable? Well, using CCS's C I do this - put this in your h file struct two_byte { BYTE lsb; BYTE msb; }; typedef union split_tag { long L; // note! a long in CCS is 16 bits struct two_byte TB; } split_type; then declare split_type a, b; a.TB.lsb = 123; // manipulate as 8 bit vars a.TB.msb = 456; b.L = a.L; // manipulate as 16 bit vars Advantage is that there is no arithmetic ops involved. Things to check are whether your C is big or little endian, and whether it supports structs / unions. MikeS