165
ATmega64A [DATASHEET]
8160D–AVR–02/2013
bits must always be read before the UDRn Register is read. Otherwise the error status will be lost since the
buffer state is lost.
The Receiver Shift Register can now act as a third buffer level. This is done by allowing the received data to
remain in the serial Shift Register (see
Figure 21-1) if the buffer registers are full, until a new start bit is
detected. The USART is therefore more resistant to Data Over Run (DORn) error conditions.
The following control bits have changed name, but have same functionality and register location:
CHR9 is changed to UCSZn2.
OR is changed to DORn.
21.3
Clock Generation
The Clock Generation logic generates the base clock for the Transmitter and Receiver. The USART supports four
modes of clock operation: Normal asynchronous, Double Speed asynchronous, Master synchronous and Slave
synchronous mode. The UMSELn bit in USART Control and Status Register n C (UCSRnC) selects between asyn-
chronous and synchronous operation. Double Speed (asynchronous mode only) is controlled by the U2Xn found in
the UCSRnB Register. When using synchronous mode (UMSELn = 1), the Data Direction Register for the XCK pin
(DDR_XCK) controls whether the clock source is internal (Master mode) or external (Slave mode). The XCK pin is
only active when using synchronous mode.
Figure 21-2 shows a block diagram of the Clock Generation logic.
Figure 21-2. Clock Generation Logic, Block Diagram
Signal description:
txclk
Transmitter clock (Internal Signal).
rxclk
Receiver base clock (Internal Signal).
xcki
Input from XCK pin (internal Signal). Used for synchronous slave operation.
xcko
Clock output to XCK pin (Internal Signal). Used for synchronous master
operation.
fosc
XTAL pin frequency (System Clock).
21.3.1
Internal Clock Generation – The Baud Rate Generator
Internal clock generation is used for the asynchronous and the synchronous master modes of operation. The
The USART Baud Rate Register n (UBRRn) and the down-counter connected to it function as a programmable
prescaler or baud rate generator. The down-counter, running at system clock (f
OSC), is loaded with the UBRRn
value each time the counter has counted down to zero or when the UBRRnL Register is written. A clock is gener-
Prescaling
Down-Counter
/ 2
UBRR
/ 4
/ 2
fosc
UBRR+1
Sync
Register
OSC
XCK
Pin
txclk
U2X
UMSEL
DDR_XCK
0
1
0
1
xcki
xcko
DDR_XCK
rxclk
0
1
0
Edge
Detector
UCPOL