29.01.2015 Views

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

STM32F101xx, STM32F102xx, STM32F103xx, STM32F105xx and ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

RM0008<br />

Universal synchronous asynchronous receiver transmitter (USART)<br />

Apart from this, the communications are similar to what is done in normal USART mode.<br />

The conflicts on the line must be managed by the software (by the use of a centralized<br />

arbiter, for instance). In particular, the transmission is never blocked by hardware <strong>and</strong><br />

continue to occur as soon as a data is written in the data register while the TE bit is set.<br />

25.3.11 Smartcard<br />

Note:<br />

The Smartcard mode is selected by setting the SCEN bit in the USART_CR3 register. In<br />

smartcard mode, the following bits must be kept cleared:<br />

● LINEN bit in the USART_CR2 register,<br />

● HDSEL <strong>and</strong> IREN bits in the USART_CR3 register.<br />

Moreover, the CLKEN bit may be set in order to provide a clock to the smartcard.<br />

The Smartcard interface is designed to support asynchronous protocol Smartcards as<br />

defined in the ISO 7816-3 st<strong>and</strong>ard. The USART should be configured as:<br />

● 8 bits plus parity: where M=1 <strong>and</strong> PCE=1 in the USART_CR1 register<br />

● 1.5 stop bits when transmitting <strong>and</strong> receiving : where STOP=’11’ in the USART_CR2<br />

register.<br />

It is also possible to choose 0.5 stop bit for receiving but it is recommended to use 1.5 stop<br />

bits for both transmitting <strong>and</strong> receiving to avoid switching between the two configurations.<br />

Figure 252 shows examples of what can be seen on the data line with <strong>and</strong> without parity<br />

error.<br />

Figure 252. ISO 7816-3 asynchronous protocol<br />

Without Parity error<br />

Guard time<br />

S 0 1 2 3 5 4 6 7 P<br />

Start<br />

bit<br />

With Parity error<br />

Guard time<br />

S 0 1 2 3 5 4 6 7 P<br />

Start<br />

bit<br />

Line pulled low<br />

by receiver during stop in<br />

case of parity error<br />

When connected to a smartcard, the TX output of the USART drives a bidirectional line that<br />

the smartcard also drives into. To do so, SW_RX must be connected on the same I/O than<br />

TX at product level. The Transmitter output enable TX_EN is asserted during the<br />

transmission of the start bit <strong>and</strong> the data byte, <strong>and</strong> is deasserted during the stop bit (weak<br />

pull up), so that the receive can drive the line in case of a parity error. If TX_EN is not used,<br />

TX is driven at high level during the stop bit: Thus the receiver can drive the line as long as<br />

TX is configured in open-drain.<br />

Smartcard is a single wire half duplex communication protocol.<br />

● Transmission of data from the transmit shift register is guaranteed to be delayed by a<br />

minimum of 1/2 baud clock. In normal operation a full transmit shift register will start<br />

Doc ID 13902 Rev 9 675/995

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!