The baud rate generator furnishes the bit period clock, or baud rate clock, for both the receiver and the transmitter. The baud rate clock is implemented by distributing the base clock UART_REF_CLK and a single cycle clock enable to achieve the effect of clocking at the appropriate frequency division. The effective logic for the baud rate generation is shown in This Figure.
The baud rate generator can use either the master clock signal, UART_REF_CLK, or the master clock divided by eight, UART_REF_CLK/8. The clock signal used is selected according to the value of the CLKS bit in the Mode register (uart.mode). The resulting selected clock is termed sel_clk in the following description.
The sel_clk clock is divided down to generate three other clocks: baud_sample, baud_tx_rate, and baud_rx_rate. The baud_tx_rate is the target baud rate used for transmitting data. The baud_rx_rate is nominally at the same rate, but gets resynchronized to the incoming received data. The baud_sample runs at a multiple ([BDIV] + 1) of baud_rx_rate and baud_tx_rate and is used to over-sample the received data.
The sel_clk clock frequency is divided by the CD field value in the Baud Rate Generator register to generate the baud_sample clock enable. This register can be programmed with a value between 1 and 65535.
The baud_sample clock is divided by [BDIV] plus 1. BDIV is a programmable field in the Baud Rate Divider register and can be programmed with a value between 4 and 255. It has a reset value of 15, inferring a default ratio of 16 baud_sample clocks per baud_tx_clock / baud_rx_rate.
The frequency of the baud_sample clock enable is shown in This Equation.
The frequency of the baud_rx_rate and baud_tx_rate clock enables is show in Equation This Equation.
IMPORTANT: It is essential to disable the transmitter and receiver before writing to the Baud Rate Generator register (uart.Baud_rate_gen), or the baud rate divider register (uart.Baud_rate_divider). A soft reset must be issued to both the transmitter and receiver before they are re-enabled.
Some examples of the relationship between the UART_REF_CLK clock, baud rate, clock divisors (CD and BDIV), and the rate of error are shown in Table: UART Parameter Value Examples. The highlighted entry shows the default reset values for CD and BDIV. For these examples, a system clock rate of UART_REF_CLK = 50 MHz and UART_REF_CLK/8 = 6.25 MHz is assumed. The frequency of the UART reference clock can be changed to get a more accurate Baud rate frequency, refer to PS Clock Subsystem for details to program the UART_REF_CLK.