GD32W51x User Manual
605
ABDM bits in the USART_CTL1 register. These methods are:
1.
The USART will measure the duration of the start bit (falling edge to rising edge). In this
case the receiving pattern should be any character starting with a bit at 1.
2.
The USART will measure the duration of the start and of the 1st data bit. The measure
is done falling edge to falling edge, ensuring a better accuracy in the case of slow signal
slopes. In this case, the receiving pattern should be any character starting with 10xx bits.
18.3.14.
ModBus communication
The USART offers basic support for the implementation of ModBus/RTU and ModBus/ASCII
protocols by implementing an end of block detection.
In the ModBus/RTU mode, the end of one block is recognized by an idle line for more than 2
characters time. This function is implemented through the programmable timeout function.
To detect the idle line, the RTEN bit in the USART_CTL1 register and the RTIE in the
USART_CTL0 register must be set. The USART_RT register must be set to the value
corresponding to a timeout of 2 characters time. After the last stop bit is received, when the
receive line is idle for this duration, an interrupt will be generated, informing the software that
the current block reception is completed.
In the ModBus/ASCII mode, the end of a block is recognized by a specific (CR/LF) character
sequence. The USART manages this mechanism using the character match function by
programming the LF ASCII code in the ADDR field and activating the address match interrupt
(AMIE=1). When a LF has been received or can check the CR/LF in the DMA buffer, the
software will be informed.
18.3.15.
Receive FIFO
The receive FIFO can be enabled by setting the RFEN bit of the USART_RFCS register to
avoid the overrun error when the CPU can’t serve the RBNE interrupt immediately. Up to 5
frames receive data can be stored in the receive FIFO and receive buffer. The RFFINT flag
will be set when the receive FIFO is full. An interrupt is generated if the RFFIE bit is set.
Figure 18-16. USART Receive FIFO structure
Rx shift
register
Rx Module
FIFO 0
FIFO 1
Rx FIFO EN
Rx Buffer
DMA
FIFO 2
FIFO 3