GD32F20x User Manual
502
deactivate the NACK transmission.
When requesting a read from the smartcard, the RT[23:0] bits in USART_RT register should
be programmed with the BWT (block wait time) - 11 value and RBNEIE must be set. This
timeout time is expressed in baudtime units. The RTF bit in USART_STAT1 will be asserted,
if no answer is received from the card before the expiration of this period. An interrupt is
generated if the RTIE bit in USART_CTL3 is set. The USART generates a RBNE interrupt if
the first character is received before the expiration of the RT[23:0] period. If DMA is used to
read from the smartcard in block mode, the DMA must be enabled only after the first character
is received.
After the first character is received, the RT[23:0] bits should be configured to the CWT
(character wait time) - 11 value to enable the automatic check of the maximum interframe gap
between two consecutive characters. The RTF bit in USART_STAT1 will be asserted, if the
smartcard stops sending characters for the RT[23:0] period.
The USART uses a block length counter, which is reset when the USART is transmitting
(TBE=0), to count the number of received characters. The length of the block, which must be
programmed to the BL[7:0] bits in the USART_RT register, is received from the smartcard in
the third byte of the block (prologue field). The block length counter counts up from 0 to the
maximum value of BL+4. The end of the block status (EBF bit in USART_STAT1) is set after
the block length counter reaches the maximum value. An interrupt is generated if the EBIE bit
in USART_CTL3 is set. The RTF bit may be set in case of an error in the block length.
If DMA is used for reception, this register field must be programmed to the minimum value
(0x0) before the start of the block. With this value, the end of the block interrupt occurs after
the 4th received character. The block length value can be read from the receive buffer at the
third byte.
If DMA is not used for reception, the BL[7:0] bits should be firstly configured with the maximum
value 0xFF to avoid generating an EBF status. The real block length value can be
reconfigured to the BL[7:0] bits after the third byte is received.
Direct and inverse convention
The smartcard protocol defines two conventions: direct and inverse.
When the directed convention is selected, the LSB of the data frame is transferred first, high
state on the TX pin represents logic
‘1’, the parity check mode is even. In this case the MSBF
and DINV bits in USART_CTL3 should be reset.
When the inverse convention is selected, the MSB of the data frame is transferred first, high
state on the TX pin represents logic
‘0’, the parity check mode is even. In this case the MSBF
and DINV bits in USART_CTL3 should be set.
19.3.13.
USART interrupts
The USART interrupt events and flags are listed in the table below.
Summary of Contents for GD32F20 Series
Page 191: ...GD32F20x User Manual 191 Bits Fields Descriptions 31 0 TRNDATA 31 0 32 Bit Random data ...
Page 290: ...GD32F20x User Manual 290 conversion is ongoing ...
Page 325: ...GD32F20x User Manual 325 15 0 ALRM 15 0 RTC alarm value low ...
Page 385: ...GD32F20x User Manual 385 ...
Page 523: ...GD32F20x User Manual 523 clears AERR bit by writing 0 to it ...