GD32F403xx User Manual
402
the TBE bit in the USART_STAT0 register is asserted. The TBE bit is cleared by writing to the
USART_DATA register and it is set by hardware after the data is put into the transmit shift
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 dat a 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_STAT0 register
will be set. An interrupt will be generated if the corresponding interrupt enable bit (TCIE) is
set in the USART_CTL0 register.
The USART transmit procedure is shown in
Figure 17-3. USART transmit procedure
. The
software operating process is as follows:
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 to be asserted.
8.
Write the data to the USART_DATA register.
9.
Repeat step7-8 for each data, if DMA is not enabled.
10.
Wait until TC=1 to finish.
Figure 17-3. USART transmit procedure
Write data0 to
USART_TDATA by
DMA or software
set by
hardware
Write data1 to
USART_TDATA by
DMA or software
Write data2 to
USART_TDATA 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 to be asserted before disabling the USART or entering
the power saving mode. This bit can be cleared by a software sequence: reading the
USART_STAT0 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 directly.
17.3.4.
USART receiver
After power on, the USART receiver can be enabled by the following 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.
Содержание GD32F403 Series
Страница 1: ...GigaDevice Semiconductor Inc GD32F403xx Arm Cortex M4 32 bit MCU User Manual Revision 2 6 Jul 2022 ...
Страница 177: ...GD32F403xx UserManual 177 Peripheral Channel 0 Channel 1 Channel 2 Channel 3 Channel 4 SDIO SDIO ...
Страница 217: ...GD32F403xx UserManual 217 ensures that no conversion is in progress ...