【STM32F10x Series】Universal Synchronous Asynchronous Receiver Transmitter (USART)

1. USART introduction

What is the USART?

The Universal Synchronous Asynchronous Receiver Transmitter (USART) offers a flexible means of full-duplex data exchange with external equipment requring an industy standard NRZ asychronous serial data format.

What is baud rate of USART?

The USART offers a very wide range of baud rates using a fractional baud rate generator.

What can the USART support?

  1. Synchronous one-way communication
  2. Half-duplex single wire communication
  3. LIN (local interconnection network)
  4. Smartcard Protocol
  5. IrDA (infrared data association) SIR ENDEC specifications
  6. Modem operations (CTS/RTS)
  7. Multiprocessor communication

How to optimize data communication of USART?

High speed data communication is possible by using the DMA for multibuffer configuraiton.

2. USART main features

Communications

  • Full duplex, asynchronous communications

Format

  • NRZ standard format (Mark/Space)
  • Programmable data word length (8 or 9 bits)
  • Configure stop bits (support for 1 or 2 stop bits)
  • Transmitter clock output for synchronous transmission

Structure

  • Fractional baud rate generator systems (a common programmable transmit and receive baud rate up to 4.5MBits/s)
  • Configurable multibuffer communication using DMA (Buffering of received / transmitted bytes in reserved SRAM using centralized DMA)
  • Separate enable bits for transmitter and receiver

Modes

  • LIN Master Synchronous Break send capability and LIN slave break detection capability (13-bit break generation and 10/11 bit break detection when USART is hardware configured for LIN)
  • IrDA SIR encodeer capability (support for 3/16 bit duration for normal mode)
  • Smartcard Emulation Capability (The Smartcard interface supports the asynchronous protocol Smartcards as defined in ISO 7816-3 standards)
  • Single wire half duplex communication
  • Multiprocessor communication (enter into mute mode if address match data not occur)
  • Wake up from mute mode (by idle line detection or address mark detection)
  • Two receiver wakeup modes: address bit (MSB, 9th bit), Idle line

Transfer detection flags

  • Receive buffer full
  • Transmit buffer empty
  • End of transmission flags

Parity control

  • Transmit parity bit
  • Check parity of received data byte

Error detection flags

  • Overrun error
  • Noise error
  • Frame error
  • Parity error

Interrupt sources with flags

  • CTS changes
  • LIN break detection
  • Transmit data register empty
  • Transmission complete
  • Receive data register full
  • Idle line received
  • Overrun error
  • Framming error
  • Noise error
  • Parity error

3. USART functional description

What is the structure of USART?

The interface is externally connected to another device by three pins. Any USART bidirectional communication requires a minimum of two pins: Receive Data in (RX) and Transmit Data out (TX).

What is the meaning of TX and RX?

TX: Transmit Data Output
When the transmitter is disabled, the output pin returns to its IO port configuration.
When the transmitter is enabled and nothing is to be transmitted, the TX pin is at high level.
In single-wire and smartcard modes, this IO is uesd to transmit and receive the data (at USART level, data are then recieved on SW_RX).

RX: Receive Data Input
RX is the serial data input. Oversampling techniques are used for data recovery by discriminating between vaild data and noise.

What is frame of normal USART?

Through these pins. serial data is transmitted and received in normal USART mode as frames comprising:

  1. An idle line prior to transmission or reception
  2. A start bit
  3. A data word (8 or 9 bits) least significant bit first
  4. Stop bits (0.5, 1, 1.5, 2) indicating that the frame is complete

What is structure of USART?

  • This interface uses a fractional baud rate generator with a 12-bit mantissa and 4-bit fraction
  • A startus register (USART_SR)
  • Data register (USART_DR)
  • A baud rate register (USART_BRR)
  • A guard-time register (USART_GTPR) in case of smartcard mode.

4. USART block diagram

usart_block_diagram

5. USART character description

What is word length in USART?

Word length may be selected as being 8 or 9 bits by programming the M bit in the USART_CR1 register.
word_length_programming)

What is the state of TX during start bit and stop bit?

The TX pin is in low state during the start bit, and it is in high state during the stop bit.

What is the idle frame?

The Idle frame is interpreted as an entire frame of "1"s follwed by the start bit of next frame which contains data (The number of “1” will includes the number of stop bits).

What is the break frame?

The break frame is interpreted on receiving "0"s for a frame period. At the end of break frame the transmitter inserts 1 or 2 stop bits (logic “1” bit) to acknowledge the start bit.

Who drives the transmission and reception?

The transmission and reception are driven by a common baud rate generator, the clock for each is generated when the enable bit is set respectively for the transmitter and receiver.

6. Transmitter

What is the descprtion of transmitter?

The transmitter can send data word of either 8 or 9 bits depending on the M bit status. When the transmit enable bit (TE) is set, the data in the transmit shift register is output on the TX pin and the corresponding clock pulses are output on the CK pin.

What is the character transmission?

During a USART transmission, data shifts out least significant bit (LSB) first on the TX pin. In this mode, the USART_DR register consists of a buffer (TDR) between the internal bus and the transmit shift register.
Every character is preceded by a start bit, which is a logic level low for one bit period.
An idle frame will be send after the TE bit is enabled.

What is the stop bit of character transmission?

The character is terminated by a configurable number of stop bits. The following stop bits are supported by USART: 0.5, 1, 1.5 and 2 stop bits.
The number of the stop bits to be transmitted with every character can be programmed in control register2:

  1. 1 stop bit: This is the default value
  2. 2 stop bits: This is supported by normal USART, single-wire and modem modes
  3. 0.5 stop bit: To be used when receiving data in smartcard mode
  4. 1.5 stop bits: To be used when transmitting and receiving data in smartcard mode

stop_bit

Why cannot reset TE bit during transmission of data?

The TE bit should not be reset during transmission of data. Resetting the TE bit during the transmission will corrupt the data on the TX pin as the baud rate counters will get forzen. The current data being transmitted will be lost

What is the produre of a break transmission

A break transmission will be 10 low bits followed by the configured number of stop bits (when m = 0) and 11 low bits followed by the configured number of stop bits (when m = 1). It is not possible to transmit long breaks (break of length greater than 10/11 low bits)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值