Parity bit calculation, Atmega32(l) – Rainbow Electronics ATmega32L User Manual

Page 143

Advertising
background image

143

ATmega32(L)

2503C–AVR–10/02

The USART Character SiZe (UCSZ2:0) bits select the number of data bits in the frame.
The USART Parity mode (UPM1:0) bits enable and set the type of parity bit. The selec-
tion between one or two stop bits is done by the USART Stop Bit Select (USBS) bit. The
receiver ignores the second stop bit. An FE (Frame Error) will therefore only be detected
in the cases where the first stop bit is zero.

Parity Bit Calculation

The parity bit is calculated by doing an exclusive-or of all the data bits. If odd parity is
used, the result of the exclusive or is inverted. The relation between the parity bit and
data bits is as follows::

P

even

Parity bit using even parity

P

odd

Parity bit using odd parity

d

n

Data bit n of the character

If used, the parity bit is located between the last data bit and first stop bit of a serial
frame.

P

even

d

n

1

d

3

d

2

d

1

d

0

0

P

o dd

d

n

1

d

3

d

2

d

1

d

0

1

=
=

Advertising