17.3.3 Clock Generation
The LEUART clock defines the transmission and reception data rate. The clock generator employs a fractional clock divider to allow
baud rates that are not attainable by integral division of the 32.768 kHz clock that drives the LEUART.
The clock divider used in the LEUART is a 14-bit value, with a 9-bit integral part and a 5-bit fractional part. The baud rate of the
LEUART is given by :
br = fLEUARTn / (1 + LEUARTn_CLKDIV / 256)
Figure 17.3. LEUART Baud Rate Equation
where fLEUARTn is the clock frequency supplied to the LEUART. The value of LEUARTn_CLKDIV thus defines the baud rate of the
LEUART. The integral part of the divider is right-aligned in the upper 24 bits of LEUARTn_CLKDIV and the fractional part is left-aligned
in the lower 8 bits. The divider is thus a 256th of LEUARTn_CLKDIV as seen in the equation.
As an example let us assume fLEUART = 22.5Khz and the value of DIV in LEUARTn_CLKDIV is 0x0028 (LEUARTn_CLKDIV =
0x00000140). The baud rate = 22.5Khz/(1 + 0x140 / 256) = 22.5Khz / 2.25 = 10Khz.
For a desired baud rate br
DESIRED
, LEUARTn_CLKDIV can be calculated by using:
LEUARTn_CLKDIV = 256 x (fLEUARTn/br
DESIRED
- 1)
Figure 17.4. LEUART CLKDIV Equation
It's important to note that this equation results in a 32bit value for the LEUARTn_CLKDIV register but only bits [16:3] are valid and all
others must be 0. For example if we have a 32Khz clock and whish to achieve a baud rate of 10Khz the equation above results in a
LEUARTn_CLKDIV value of 0x233. However, the actual value of the register will be 0x230 since bits [2:0] cannot be set. This limits the
best achievable acuracy. In this example the actual baud rate wil be 32Khz / (1+ 0x230/255) = 10.039Khz instead of 32Khz /
(1+ 0x233/255) = 10.002Khz.
Table 17.2 LEUART Baud Rates on page 545
lists a set of desired baud rates and the closest baud rates reachable by the LEUART
with a 32.768 kHz clock source. It also shows the average baud rate error.
Table 17.2. LEUART Baud Rates
Desired baud rate
LEUARTn_CLKDIV
LEUARTn_CLKDIV/256
Actual baud rate
Error [%]
300
27704
108,21875
300,0217
0.01
600
13728
53,625
599,8719
-0.02
1200
6736
26,3125
1199,744
-0.02
2400
3240
12,65625
2399,487
-0.02
4800
1488
5,8125
4809,982
0.21
9600
616
2,40625
9619,963
0.21
17.3.4 Data Transmission
Data transmission is initiated by writing data to the transmit buffer using one of the methods described in
17.3.4.1 Transmit Buffer Oper-
. When the transmit shift register is empty and ready for new data, a frame from the transmit buffer is loaded into the shift register,
and if the transmitter is enabled, transmission begins. When the frame has been transmitted, a new frame is loaded into the shift regis-
ter if available, and transmission continues. If the transmit buffer is empty, the transmitter goes to an idle state, waiting for a new frame
to become available. Transmission is enabled through the command register LEUARTn_CMD by setting TXEN, and disabled by setting
TXDIS. When the transmitter is disabled using TXDIS, any ongoing transmission is aborted, and any frame currently being transmitted
is discarded. When disabled, the TX output goes to an idle state, which by default is a high value. Whether or not the transmitter is
enabled at a given time can be read from TXENS in LEUARTn_STATUS. After a transmission, when there is no more data in the shift
register or transmit buffer, the TXC flag in LEUARTn_STATUS and the TXC interrupt flag in LEUARTn_IF are set, signaling that the
transmitter is idle. The TXC status flag is cleared when a new byte becomes available for transmission, but the TXC interrupt flag must
be cleared by software.
EFM32JG1 Reference Manual
LEUART - Low Energy Universal Asynchronous Receiver/Transmitter
silabs.com
| Smart. Connected. Energy-friendly.
Preliminary Rev. 0.6 | 545