Nations Technologies Inc.
Tel
:
+86-755-86309900
:
Address: Nations Tower, #109 Baoshen Road, Hi-tech Park North.
Nanshan District, Shenzhen, 518057, P.R.China
459
/
631
5.
After writing the last data word in the USART_DAT register, wait for USART_STS.TXC =1, which indicates
the end of the transmission of the last data frame.
Single byte communication
A write to the USART_DAT register clears the USART_STS.TXDE bit.
The USART_STS.TXDE bit is set by hardware when the data in the TDR register is transferred to the transmit shift
register (indicating that data is being transmitted). An interrupt will be generated if USART_CTRL1.TXDEIEN is
set. At this point, the next data can be sent to the USART_DAT register because the TDR register has been cleared
and will not overwrite the previous data.
Write operation to USART_DAT register:
When the transmit shift register is not sending data and is in an idle state, the data is directly put into the shift
register for transmission, and the USART_STS.TXDE bit is set by hardware;
When the transmit shift register is sending data, the data is stored in the TDR register, and after the current
transmission is completed, the data is put into the shift register.
When a frame containing data is sent and USART_STS.TXDE=1, the USART_STS.TXC bit is set to '1' by hardware.
An interrupt is generated if USART_CTRL1.TXCIEN is '1'. USART_STS.TXC bit is cleared by a software sequence
(read USART_STS register first, then write USART_DAT register).
Figure 22-5 TXC/TXDE changes during transmission
Receiver
Start bit detection
When the received sampling sequence is: 1 1 1 0 X 0 X 0 X 0 0 0 0, it is considered that a start bit is detected.
The samples at the 3rd, 5th, and 7th bits, and the samples at the 8th, 9th, and 10th bits are all '0' (that is, 6 '0'), then
TX line
TXDE flag
USART_DAT
TXC flag
Idle
Frame 1
Frame 2
Frame 3
set by hardware
cleared by software
set by hardware
cleared by software
set by hardware
data1
data2
data3
USART
enable
Write data1
into USART_DAT
Because TXDE=1
TXC is set
Set by
hardware
Write data2
into USART_DAT
Write data2
into USART_DAT