www
.mcu.com.cn
197
/
239
Rev.
1.00
CMS80F731x Reference Manual
22.
UARTn Module
22.1 Overview
The Universal Synchronous Asynchronous Transceiver (UART0/UART1) provides a flexible way to exchange full-duplex
data with external devices.
UARTn has two physically separate receive and transmit buffers, SBUFn, which distinguish between operations on a receive
buffer or a transmit buffer by reading and writing instructions to SBUFn. When writing SBUFn, data is loaded into the send buffer;
When reading SBUFn, the contents of the receive buffer are read.
UARTn has four modes of operation: one synchronous mode and three asynchronous modes. Modes 2 and 3 have a multi-
machine communication function that is enabled by placing SMn2 bit set to 1 in the SCONN register. The master processor first
sends the address byte that identifies the target slave. Address bytes are different from data bytes in that bit 9 in the address
byte is 1 and data bytes are 0. At SMn2=1, the slave is not interrupted by bytes of data. The address byte will interrupt all slaves.
The addressed slave will clear its SMn2 bits and prepare to receive incoming bytes of data. The unaddressed slave sets smn2
to 1 and ignores the incoming data.
22.2 UARTn Port Configuration
Before using the UARTn module, you need to configure the corresponding port as the TXDn and RXDn channels of UARTn.
For example, the port configuration of UART0 is as follows:
PS_RXD0 = 0x05; Select P05 as the RXD0 pin
P05CFG = 0x02; P05 multiplexing for RXD0 function
P04CFG = 0x02; P04 multiplexing for TXD0 function
UARTn's port RXDn can be selected by PS_RXDn (only one of the RXDn pins can be selected), and the TXDn port can be
selected by the port configuration register (either at the same time or by selecting one of them). If selected at the same time, the
corresponding waveform will be output).
When using, it is recommended to set the working mode first, and then configure the corresponding port as a serial port.