Datasheet
19.4 Initialization and Configuration
To enable and initialize the UART, the following steps are necessary:
1. Enable the UART module using the RCGCUART register (see page 395).
2. Enable the clock to the appropriate GPIO module via the RCGCGPIO register (see page 389).
To find out which GPIO port to enable, refer to Table 29-5 on page 1932.
3. Set the GPIO AFSEL bits for the appropriate pins (see page 778). To determine which GPIOs to
configure, see Table 29-4 on page 1921.
4. Configure the GPIO current level and/or slew rate as specified for the mode selected (see
page 780 and page 788).
5. Configure the PMCn fields in the GPIOPCTL register to assign the UART signals to the appropriate
pins (see page 795 and Table 29-5 on page 1932).
To use the UART, the peripheral clock must be enabled by setting the appropriate bit in the
RCGCUART register (page 395). In addition, the clock to the appropriate GPIO module must be
enabled via the RCGCGPIO register (page 389) in the System Control module. To find out which
GPIO port to enable, refer to Table 29-5 on page 1932.
This section discusses the steps that are required to use a UART module. For this example, the
UART clock is assumed to be 20 MHz, and the desired UART configuration is:
■ 115200 baud rate
■ Data length of 8 bits
■ One stop bit
■ No parity
■ FIFOs disabled
■ No interrupts
The first thing to consider when programming the UART is the baud-rate divisor (BRD), because
the UARTIBRD and UARTFBRD registers must be written before the UARTLCRH register. Using
the equation described in “Baud-Rate Generation” on page 1289, the BRD can be calculated:
BRD = 20,000,000 / (16 * 115,200) = 10.8507
which means that the DIVINT field of the UARTIBRD register (see page 1308) should be set to 10
decimal or 0xA. The value to be loaded into the UARTFBRD register (see page 1309) is calculated
by the equation:
UARTFBRD[DIVFRAC] = integer(0.8507 * 64 + 0.5) = 54
With the BRD values in hand, the UART configuration is written to the module in the following order:
1. Disable the UART by clearing the UARTEN bit in the UARTCTL register.
2. Write the integer portion of the BRD to the UARTIBRD register.
3. Write the fractional portion of the BRD to the UARTFBRD register.
June 18, 20141296
Texas Instruments-Production Data
Universal Asynchronous Receivers/Transmitters (UARTs)