Parity
Line noise and similar problems can “flip” bits, converting a zero bit to a one bit or vice versa and thereby corrupting the data word. Using a parity bit is a primitive means of detecting a flipped bit. If parity is used, the transmitting device calculates the value for the parity bit based on the values of the data bits in the word. The receiving device calculates the value of the parity bit based on the data bits it receives, and compares that calculated parity bit against the received parity bit. If the two do not match, the receiving device knows that a transmission error occurred and requests retransmission of that frame. Serial devices may use one of five types of parity settings, only two of which are useful for detecting transmission errors:
- Even parity
Even parity (E) sets the parity bit to one or zero to force the total number of one-bits in the data word plus the parity bit to an even number. For example, if a byte contains the seven data bits 1-1-0-1-0-0-1 (four one-bits, which is an even number), the parity bit is set to zero for even parity, leaving the total number of one-bits in the eight-bit byte at four, an even number. Conversely, if a byte contains the seven data bits 1-1-0-1-0-1-1 (five one-bits, which is an odd number), the parity bit is set to one for even parity, forcing the total number of one-bits in the eight-bit byte to six, again an even number. Even parity with seven-bit data words was commonly used years ago for dial-up and direct serial connections ...