一、Initialization
The following steps are required to initialize the UART:
0.给UART模块上电
1.Perform the necessary device pin multiplexing setup (see your device-specific data manual).
2.Set the desired baud rate by writing the appropriate clock divisor values to the divisor latch registers(DLL and DLH).
Divisor = UART input clock frequency/(Desired baud rate * 16) 当 MDR.OSM _ SEL = 0
Divisor = UART input clock frequency/(Desired baud rate * 13) 当 MDR.OSM _ SEL = 1
3.If the FIFOs will be used(FIFOEN =1 in FCR),The FIFOEN bit in FCR must be set first, before the other bits in FCR are configured. Select the desired trigger level and enable the FIFOs by writing the appropriate values to the FIFO control register (FCR). Clear the transmitter FIFO and Receiver FIFO by set TXCLR=1 and RXCLR =1.
4.Choose the desired protocol settings by writing the appropriate values to the line control register(LCR). e.g. set PEN =0(No PARITY),STB=0(1stop bit),WLS=0x3(8bits)
5.set IER controller if you need interrupt.
6.If autoflow control is desired, write appropriate values to the modem control register (MCR). Note thatall UARTs do not support autoflow control, see your d