DocID025202 Rev 7
854/1080
RM0365
Universal synchronous asynchronous receiver transmitter (USART)
901
Note:
and
may slightly differ in the special case when
the received frames contain some Idle frames of exactly 10-bit durations when M bits = 00
(11-bit durations when M bits =01 or 9- bit durations when M bits = 10).
29.5.6
USART auto baud rate detection
The USART is able to detect and automatically set the USART_BRR register value based
on the reception of one character. Automatic baud rate detection is useful under two
circumstances:
•
The communication speed of the system is not known in advance
•
The system is using a relatively low accuracy clock source and this mechanism allows
the correct baud rate to be obtained without measuring the clock deviation.
The clock source frequency must be compatible with the expected communication speed
(when oversampling by 16, the baud rate is between f
CK
/65535 and f
CK
/16. when
oversampling by 8, the baud rate is between f
CK
/65535 and f
CK
/8).
Before activating the auto baud rate detection, the auto baud rate detection mode must be
chosen. There are various modes based on different character patterns.
They can be chosen through the ABRMOD[1:0] field in the USART_CR2 register. In these
auto baud rate modes, the baud rate is measured several times during the synchronization
data reception and each measurement is compared to the previous one.
These modes are:
•
Mode 0
: Any character starting with a bit at 1. In this case the USART measures the
duration of the Start bit (falling edge to rising edge).
•
Mode 1:
Any character starting with a 10xx bit pattern. In this case, the USART
measures the duration of the Start and of the 1st data bit. The measurement is done
falling edge to falling edge, ensuring better accuracy in the case of slow signal slopes.
•
Mode 2
: A 0x7F character frame (it may be a 0x7F character in LSB first mode or a
0xFE in MSB first mode). In this case, the baud rate is updated first at the end of the
start bit (BRs), then at the end of bit 6 (based on the measurement done from falling
edge to falling edge: BR6). Bit 0 to bit 6 are sampled at BRs while further bits of the
character are sampled at BR6.
•
Mode 3
: A 0x55 character frame. In this case, the baud rate is updated first at the end
of the start bit (BRs), then at the end of bit 0 (based on the measurement done from
falling edge to falling edge: BR0), and finally at the end of bit 6 (BR6). Bit 0 is sampled
Table 156. Tolerance of the USART receiver when BRR [3:0] is different from 0000
M bits
OVER8 bit = 0
OVER8 bit = 1
ONEBIT=0
ONEBIT=1
ONEBIT=0
ONEBIT=1
00
3.33%
3.88%
2%
3%
01
3.03%
3.53%
1.82%
2.73%
10
3.7%
4.31%
2.22%
3.33%