GD32F10x User Manual
432
register. If a data is written to the USART_DATA register while a transmission is ongoing, it
will be firstly stored in the transmit buffer, and transferred to the transmit shift register after
the current transmission is done. If a data is written to the USART_DATA register while no
transmission is ongoing, the TBE bit will be cleared and set soon, because the data will be
transferred to the transmit shift register immediately.
If a frame is transmitted and the TBE bit is asserted, the TC bit of the USART_STAT register
will be set. An interrupt is generated if the corresponding interrupt enable bit (TCIE) is set in
the USART_CTL0 register.
The USART transmit procedure is shown in
Figure 16-3. USART transmit procedure
. The
software can follow this flow:
1.
Set the UEN bit in USART_CTL0 to enable the USART.
2.
Write the WL bit in USART_CTL0 to set the data bits length.
3.
Set the STB[1:0] bits in USART_CTL1 to configure the number of stop bits.
4.
Enable DMA (DENT bit) in USART_CTL2 if multibuffer communication is selected.
5.
Set the baud rate in USART_BAUD.
6.
Set the TEN bit in USART_CTL0.
7.
Wait for the TBE being asserted.
8.
Write the data to in the USART_DATA register.
9.
Repeat step7-8 for each data, if DMA is not enabled.
10.
Wait until TC=1 to finish.
Figure 16-3. USART transmit procedure
Write data0 to
USART_DATA by
DMA or software
set by
hardware
Write data1 to
USART_DATA by
DMA or software
Write data2 to
USART_DATA by
DMA or software
set by
hardware
set by
hardware
USART_DATA
TBE
TEN
TX pin
idle frame
frame0
frame1
frame2
data0
data1
data2
set by
hardware
cleared
by
software
TC
It is necessary to wait for the TC bit asserted before disabling the USART or entering the
power saving mode. This bit can be cleared by a software sequence: reading the
USART_STAT register and then writing the USART_DATA register. If the multibuffer
communication is selected (DENT=1), this bit can also be cleared by writing 0 to it directly.
16.3.4.
USART receiver
After power on, the USART receiver can be enabled by the follow procedure:
1.
Set the UEN bit in USART_CTL0 to enable the USART.
2.
Write the WL bit in USART_CTL0 to set the data bits length.
Summary of Contents for GD32F10 Series
Page 63: ...GD32F10x User Manual 63 programmed during the chip production ...
Page 117: ...GD32F10x User Manual 117 010 1 0 011 0 9 ...
Page 416: ...GD32F10x User Manual 416 shadow register updates every update event ...
Page 427: ...GD32F10x User Manual 427 value ...
Page 518: ...GD32F10x User Manual 518 These bits are not used in SPI mode ...