www.geehy.com Page 248
When USART enters single-line half-duplex mode:
CLKEN bit of USART_CTRL2 register must be cleared.
RX pin is disabled.
TX pin should be configured as open-drain output and connected with
RX pin inside the chip.
Transmitting data and receiving data cannot be carried out at the same
time. The data cannot be received before they are transmitted. If
needing to receive data, enabling receiving can be turned on only after
TXCFLG bit of USART_STS register is set to 1.
If there is data conflict on the bus, software management is needed to
allocate the communication process.
Frame Format
The frame format of data frame is controlled by USART_CTRL1 register
The character length is controlled by DBLCFG bit, and can be set to 7,
8 or 9 bits
The PCEN bit controls whether to turn on the check bit
The PCFG bit controls the check bit is odd or even
Table 66 USART Frame Format
DBLCFG bit
PCEN bit
USART data frame
0
0
Start bit+8-bit data+stop bit
0
1
Start bit+7-bit data+odd-even parity check bit+stop bit
1
0
Start bit+9-bit data+stop bit
1
1
Start bit+8-bit data+odd-even parity check bit+stop bit
10
0
Start bit+7-bit data+stop bit
10
1
Start bit+6-bit data+parity check bit+stop bit
Configurable stop bit
Different stop bits can be configured by STOPCFG bit of USART_CTRL2
register.
1 stop bit: The default stop bit
2 stop bits: Used in normal mode, single-line mode and hardware flow
control mode
Check bit
PCFG bit of USART_CTRL1 determines the parity check bit; when PCFG=0, it is
even parity check, on the contrary, it is odd parity check.
Even check: When the number of frame data and check bit '1' is even,
the even check bit is 0; otherwise it is 1.
Odd check: When the number of frame data and check bit '1' is even,
the odd check bit is 1; otherwise it is 0.
Check generation: When transmitting data, set PCEN bit of
USART_CTRL1 register, and the check bit will replace the MSB bit of
the data and be transmitted.
Parity check:
-
If the parity check fails, PEFLG flag bit of USART_STS register will
be set.