299
8331B–AVR–03/12
Atmel AVR XMEGA AU
Figure 23-5.
Frame formats.
23.4.1
Parity Bit Calculation
Even or odd parity can be selected for error checking. If even parity is selected, the parity bit is
set to one if the number of logical one data bits is odd (making the total number of ones even). If
odd parity is selected, the parity bit is set to one if the number of logical one data bits is even
(making the total number of ones odd).
23.4.2
SPI Frame Formats
The serial frame in SPI mode is defined to be one character of eight data bits. The USART in
master SPI mode has two selectable frame formats:
• 8-bit data, msb first
• 8-bit data, lsb first
After a complete, 8-bit frame is transmitted, a new frame can directly follow it, or the communica-
tion line can return to the idle (high) state.
23.5
USART Initialization
USART initialization should use the following sequence:
1.
Set the TxD pin value high, and optionally set the XCK pin low.
2.
Set the TxD and optionally the XCK pin as output.
3.
Set the baud rate and frame format.
4.
Set the mode of operation (enables XCK pin output in synchronous mode).
5.
Enable the transmitter or the receiver, depending on the usage.
For interrupt-driven USART operation, global interrupts should be disabled during the
initialization.
Before doing a re-initialization with a changed baud rate or frame format, be sure that there are
no ongoing transmissions while the registers are changed.
23.6
Data Transmission - The USART Transmitter
When the transmitter has been enabled, the normal port operation of the TxD pin is overridden
by the USART and given the function as the transmitter's serial output. The direction of the pin
must be set as output using the direction register for the corresponding port. For details on port
pin control and output configuration, refer to
.
St
Start bit, always low.
(n)
Data bits (0 to 8).
P
Parity bit, may be odd or even.
Sp
Stop bit, always high.
IDLE
No transfers on the communication line (RxD or TxD). The IDLE state is always high.
1
0
2
3
4
[5]
[6]
[7]
[8]
[P]
St
Sp1 [Sp2] (St / IDLE)
(IDLE)
FRAME