
CH32V003
Reference Manual
V1.3
134
setting on the M (word length) bit, and finally a configurable number of stop bits. If equipped with a parity
check bit, the last bit of the data word is the check bit. After the TE is set an idle frame is sent, which is 10 or
11 bits high and contains the stop bit. The disconnect frame is 10 or 11 bits low followed by the stop bit.
12.3 Baud rate generator
The baud rate of the transceiver = FCLK/(16*USARTDIV), FCLK is the clock of APBx, i.e. PCLK1 or PCLK2,
the USART1 module uses PCLK2 and the rest uses PCLK1. The value of USARTDIV is determined by the
two fields DIV_M and DIV_F in USART_BRR, which is calculated by the formula The formula is as follows.
USARTDIV = DIV_M+(DIV_F/16)
It is important to note that the bit rate generated by the baud rate generator may not always generate exactly
the baud rate required by the user, and there may be deviations. In addition to taking as close a value as possible,
a way to reduce the deviation is to increase the APBx clock. For example, if you set the baud rate to 115200bps,
the value of USARTDIV is set to 39.0625, which will give you a baud rate of exactly 115200bps at the highest
frequency, but if you need a baud rate of 921600bps, the calculated USARTDIV is 4.88, but the closest value
filled in USART_BRR is actually only 4.875. 4.875, the actual baud rate is 923076bps, which is 0.16% error.
When the serial waveform sent by the sender is transmitted to the receiver, the baud rate of the receiver and
the sender is subject to some error. The error mainly comes from three aspects: the actual baud rate of the
receiver and the sender is not the same; the receiver and the sender's clock has errors; the waveform in the line
generated by the change. Peripheral module receiver is a certain receiving tolerance, when the sum of the
above three aspects of the total deviation is less than the module's tolerance limit, the total deviation does not
affect the transmission and reception. The tolerance limitof the module is affected by whether to use fractional
baud rate and M-bit (data field word length), using fractional baud rate and using 9-bit data field length will
reduce the tolerance limit, but not less than 3%.
12.4 Synchronous mode
Synchronous mode allows the system to output a clock signal when using the USART module. When
synchronous mode is enabled to send data externally, the CK pin will output the clock externally at the same
time.
The way to turn on the synchronous mode is to the CLKEN position bit in control register 2
(R16_USARTx_CTLR2), but also need to turn off the LIN mode, smart card mode, infrared mode and half
duplex mode, i.e. ensure that the SCEN, HDSEL and IREN bits are in reset, these three in control register 3
(R16_USARTx_CTLR3).
The key point of using synchronous mode is the clock output control. There are several points to note.
a)
The USART module synchronization mode works only in the main mode, i.e. the CK pin outputs only
the clock and does not receive inputs.
Outputs a clock signal only when data is output on the TX pin.
The LBCL bit determines whether the clock is output when the last data bit is sent, the CPOL bit
determines the polarity of the clock, and the CPHA determines the phase of the clock. These three bits
are in control register 2 (R16_USARTx_CTLR2), which needs to be set when TE and RE are not enabled,
see Figure 12-2 for the differences.
The receiver will only sample at the output clock in synchronous mode, requiring a certain amount of
signal build time and hold time from the device, as shown in Figure 12-3.