By "do this" I assume you mean check the parity?

Here's a potential starting point:

`unsigned theValue; // 16-bit value from external device`

// I'm assuming the "first bit" is the LSB and the "last bit" is the MSB

unsigned evenParity = (theValue & (1<<0)) ? 1 : 0;

unsigned oddParity = (theValue & (1<<15)) ? 1 : 0;

unsigned firstParity, secondParity, bit;

// Compute parity over first set of 7 bits past even parity bit

for (bit=1, firstParity=0; bit < 8; bit++) {

firstParity ^= (theValue & (1<<bit)) ? 1 : 0;

}

// Compute parity over next set of 7 bits

for (bit=8, secondParity=0; bit < 15; bit++) {

secondParity ^= (theValue & (1<<bit)) ? 1 : 0;

}

// Now do comparisons of firstParity vs. evenParity and secondParity vs. oddParity

Efficiencies can be realized in the above but hopefully this is more clear than efficient

--

The

Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons