GD32A50x User Manual
485
programming the BL value. However, before the start of the block, the maximum value of BL
(0xFF) may be programmed. The real value will be programmed after the reception of the
third character.
The total block length (including prologue, epilogue and information fields) equals BL+4. The
end of the block is signaled to the software through the EBF flag and interrupt (when EBIE bit
is set). The RT interrupt may occur in case of an error in the block length.
Direct and inverse convention
The smartcard protocol defines two conventions: direct and inverse.
The direct convention is defined as: LSB first, logical bit value of 1 corresponds to H state of
the line and parity is even. In this case, the following control bits must be programmed:
MSBF=0, DINV=0 (default values).
The inverse convention is defined as: MSB first, logical bit value 1 corresponds to an L state
on the signal line and parity is even. In this case, the following control bits must be
programmed: MSBF=1, DINV=1.
19.3.13.
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.
19.3.14.
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.