beautypg.com

Parity generator, Disabling the transmitter, Data reception – the usart receiver – Rainbow Electronics ATmega8515L User Manual

Page 140: Atmega8515(l)

background image

140

ATmega8515(L)

2512A–AVR–04/02

empty interrupt, otherwise a new interrupt will occur once the interrupt routine
terminates.

The Transmit Complete (TXC) flag bit is set one when the entire frame in the transmit
Shift Register has been shifted out and there are no new data currently present in the
transmit buffer. The TXC flag bit is automatically cleared when a transmit complete inter-
rupt is executed, or it can be cleared by writing a one to its bit location. The TXC flag is
useful in half-duplex communication interfaces (like the RS-485 standard), where a
transmitting application must enter Receive mode and free the communication bus
immediately after completing the transmission.

When the Transmit Compete Interrupt Enable (TXCIE) bit in UCSRB is set, the USART
Transmit Complete Interrupt will be executed when the TXC flag becomes set (provided
that global interrupts are enabled). When the transmit complete interrupt is used, the
interrupt handling routine does not have to clear the TXC flag, this is done automatically
when the interrupt is executed.

Parity Generator

The Parity Generator calculates the parity bit for the serial frame data. When parity bit is
enabled (UPM1 = 1), the transmitter control logic inserts the parity bit between the last
data bit and the first stop bit of the frame that is sent.

Disabling the Transmitter

The disabling of the Transmitter (setting the TXEN to zero) will not become effective
until ongoing and pending transmissions are completed (i.e., when the Transmit Shift
Register and Transmit Buffer Register do not contain data to be transmitted). When dis-
abled, the Transmitter will no longer override the TxD pin.

Data Reception – The
USART Receiver

The USART Receiver is enabled by writing the Receive Enable (RXEN) bit in the
UCSRB Register to one. When the Receiver is enabled, the normal pin operation of the
RxD pin is overridden by the USART and given the function as the receiver’s serial
input. The baud rate, mode of operation and frame format must be set up once before
any serial reception can be done. If synchronous operation is used, the clock on the
XCK pin will be used as transfer clock.