Universal synchronous asynchronous receiver transmitter (USART)
RM0365
851/1080
DocID025202 Rev 7
29.5.4
USART baud rate generation
The baud rate for the receiver and transmitter (Rx and Tx) are both set to the same value as
programmed in the USART_BRR register.
Equation 1: Baud rate for standard USART (SPI mode included) (OVER8 = 0 or 1)
In case of oversampling by 16, the equation is:
In case of oversampling by 8, the equation is:
Equation 2: Baud rate in Smartcard, LIN and IrDA modes (OVER8 = 0)
In Smartcard, LIN and IrDA modes, only Oversampling by 16 is supported:
USARTDIV is an unsigned fixed point number that is coded on the USART_BRR register.
•
When OVER8 = 0, BRR = USARTDIV.
•
When OVER8 = 1
–
BRR[2:0] = USARTDIV[3:0] shifted 1 bit to the right.
–
BRR[3] must be kept cleared.
–
BRR[15:4] = USARTDIV[15:4]
Note:
The baud counters are updated to the new value in the baud registers after a write operation
to USART_BRR. Hence the baud rate register value should not be changed during
communication.
In case of oversampling by 16 or 8, USARTDIV must be greater than or equal to 0d16.
How to derive USARTDIV from USART_BRR register values
Example 1
To obtain 9600 baud with f
CK
= 8 MHz.
•
In case of oversampling by 16:
USARTDIV = 8 000 000/9600
BRR = USARTDIV = 833d = 0341h
•
In case of oversampling by 8:
USARTDIV = 2 * 8 000 000/9600
USARTDIV = 1666,66 (1667d = 683h)
BRR[3:0] = 3h >> 1 = 1h
BRR = 0x681
Tx/Rx baud
f
CK
USARTDIV
--------------------------------
=
Tx/Rx baud
2
f
CK
×
USARTDIV
--------------------------------
=
Tx/Rx baud
f
CK
USARTDIV
--------------------------------
=