A96G140/A96G148/A96A148 User’s manual
16. USART 2
199
this bit field. Writin
g ‘1’ to this field is not valid.
When Data Register Empty Interrupt Enable (UDRIE) bit in UCTRL2 register is set and Global Interrupt
is enabled, USART2 Data Register Empty Interrupt is generated while UDRE flag is set.
Transmit Complete (TXC) flag bit is set when the entire frame in the transmit shift register has been
shifted out and there are no more data in the transmit buffer. The TXC flag is automatically cleared
when the Transmit Complete Interrupt service routine is executed, or it can be cleared
by writing ‘0’ to
TXC bit in USTAT register.
When Transmit Complete Interrupt Enable (TXCIE) bit in UCTRL2 register is set and the Global
Interrupt is enabled, USART2 Transmit Complete Interrupt is generated while TXC flag is set.
16.7.3
Parity generator
Parity Generator calculates the parity bit for the sending serial frame data. When parity bit is enabled
(UPM[1] = 1), transmitter control logic inserts the parity bit between bits and the first stop bit of the
sending frame.
16.7.4
Disabling transmitter
Disabling the Transmitter by clearing TXE bit will not become effective until ongoing transmission is
completed. When the Transmitter is disabled, the TXD2 pin is used as normal General Purpose I/O
(GPIO) or primary function pin.
16.8
USART2 receiver
USART2 Receiver is enabled by setting the RXE bit in the UCTRL1 register. When the Receiver is
enabled, normal pin operation of RXD2 pin is overridden by the USART2 as the serial input pin of the
Receiver. Baud rate, mode of operation and frame format must be set before serial reception. If
synchronous or SPI operation is used, a clock on the XCK pin will be used as a transfer clock. If the
USART2 operates in SPI mode, SS2 pin is used as SS2 input pin in slave mode or can be configured
as SS2 output pin in master mode. This can be done by setting SPISS bit in UCTRL3 register.
16.8.1
Receiving Rx data
When USART2 is in synchronous or asynchronous operation mode, the Receiver starts data reception
when it detects a valid start bit (LOW) on RXD2 pin. Each bit following the start bit is sampled at pre-
defined baud rate (asynchronous) or sampling edge of XCK (synchronous), and shifted into a receive
shift register until the first stop bit of a frame is received.
Even if there’s 2nd stop bit in the frame, the 2nd stop bit is ignored by the Receiv
er. That is, receiving
the first stop bit means that a complete serial frame is present in the receiver shift register and contents
of the shift register are to be moved into the receive buffer. The receive buffer is read by reading the
UDATA register.