A96G140/A96G148/A96A148 User’s manual
15. USI
163
P
even
= Dn-
1 ^ … ^ D3 ^ D2 ^ D1 ^ D0 ^ 0
P
odd
= Dn-
1 ^ … ^ D3 ^ D2 ^ D1 ^ D0 ^ 1
P
even
: Parity bit using even parity
P
odd
: Parity bit using odd parity
D
n
: Data bit n of the character
15.8
USIn UART transmitter
The UART transmitter is enabled by setting the TXEn bit in USInCR2 register. When the Transmitter is
enabled, the TXDn pin should be set to TXDn function for the serial output pin of UART by the
P4FSR[3:2] and P2FSR[1:0].The baud-rate, operation mode and frame format must be set up once
before doing any transmission. In synchronous operation mode, the SCKn pin is used as transmission
clock, so it should be selected to do SCKn function by P4FSR[5:4] and P2FSR[3:2].
15.8.1
USIn UART sending TX data
A data transmission is initiated by loading the transmit buffer (USInDRregister I/O location) with the
data to be transmitted. The data be written in transmit buffer is moved to the shift register when the shift
register is ready to send a new frame. The shift register is loaded with the new data if it is in idle state
or immediately after the last stop bit of the previous frame is transmitted. When the shift register is
loaded with new data, it will transfer one complete frame according to the settings of control registers.
If the 9-bit characters are used in asynchronous or synchronous operation mode, the ninth bit must be
written to the USInTX8 bit in USInCR3 register before it is loaded to the transmit buffer (USInDR
register).
15.8.2
USIn UART transmitter flag and interrupt
The USART transmitter has two flags which indicate its state. One is USART data register empty flag
(DREn) and the other is transmit completion flag (TXCn). Both flags can be interrupt sources.
DREn flag indicates whether the transmit buffer is ready to receive new data. This bit is set when the
transmit buffer is empty and cleared when the transmit buffer contains data to be transmitted but has
not yet been moved into the shift register. And als
o this flag can be cleared by writing ‘0’ to this bit
position. Writing ‘1’ to this bit position is
prohibited.
When the data register empty interrupt enable (DRIEn) bit in USInCR2 register is set and the global
interrupt is enabled, USInST1 status register empty interrupt is generated while DREn flag is set.
The transmit complete (TXCn) flag bit is set when the entire frame in the transmit shift register has been
shifted out and there is no more data in the transmit buffer.