www.geehy.com Page 250
(
3
)
If USART is in idle state, write to the data register, put the data into the
shift register, start transmitting data, and set TXBEFLG bit to 1.
(
4
)
When a data transmission is completed and TXBEFLG bit is set,
TXCFLG bit will be set to 1; at this time if TXCIEN bit in USART_CTRL1
register is set to 1, an interrupt will be generated.
(
5
)
After the last data is written in the USART_TXDATA register, before
entering the low-power mode or before closing the USART module, wait
to set TXCFLG to 1.
21.4.3.3
Break frame
It is regarded that the break frames all receive '0' within one frame period. One
break frame can be transmitted by setting TXBFQ bit of USART_REQUEST
register, and the length of the break frame is determined by DBLCFG bit of
USART_CTRL1 register. If the TXBFQ bit is set, after completion of transmission
of current data, the TX line will transmit a break frame, and after completion of
transmission of break frame, this bit will be reset. At the end of the break frame,
the transmitter inserts 1 or 2 stop bits to respond to the start bit.
Note: If the TXBFQ bit is reset before transmission of the break frame starts, the break frame will not be
transmitted. To transmit two consecutive break frames, the TXBFQ bit should be set after the stop bit of
the previous break symbol.
21.4.3.4
Idle frame
The idle frame is regarded as a complete data frame composed entirely of '1',
followed by the start bit of the next frame containing the data. Set TXEN bit of
USART_CTRL1 register to 1 and one idle frame can be set before the first data
frame.
Receiver
21.4.4.1
Character receive
During receiving period of USART, RX pin will first introduce the least significant
bit of the data. In this mode, USART_RXDATA register has a buffer between the
internal bus and the receive shift register. The data is transmitted to the buffer bit
by bit. When fully receiving the data, the corresponding receive register is not
empty, then the user can read USART_RXDATA.
Receiving configuration steps
(
1
)
The programming oversampling rate is 8 or 16 times
(
2
)
Decide the word length by setting DBLCFG bit of USART_CTRL1
register
(
3
)
Decide the number of stop bits by setting STOPCFG bit of
USART_CTRL2 register
(
4
)
If multi-buffer communication is selected, DMA should be enabled in
USART_CTRL3 register
(
5
)
Set the baud rate of communication in USART_BR register
(
6
)
Set UEN bit of USART_CTRL1 register to enable USART
(
7
)
Set RXEN bit of USART_CTRL1 to enable receiving