Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
162
Добавлен:
01.03.2016
Размер:
3.56 Mб
Скачать

RM0016

Universal asynchronous receiver transmitter (UART)

 

 

22.3.9UART synchronous communication

 

The UART transmitter allows the user to control bidirectional synchronous serial

 

communications in master mode.

 

In synchronous mode, the following bits must be kept cleared:

 

LINEN bit in the UART_CR3 register

 

SCEN, HDSEL and IREN bits in the UART_CR5 register

Note:

This feature is only available in UART1, UART2 and UART4.

 

The UART_CK pin is the output of the UART transmitter clock. No clock pulses are sent to

 

the UART_CK pin during start bit and stop bit. Depending on the state of the LBCL bit in the

 

UART_CR3 register clock pulses will or will not be generated during the last valid data bit

 

(address mark). The CPOL bit in the UART_CR3 register allows the user to select the clock

 

polarity, and the CPHA bit in the UART_CR3 register allows the user to select the phase of

 

the external clock (see Figure 122, Figure 123 & Figure 124).

 

During idle and break frames, the external CK clock is not activated.

 

In synchronous mode, the UART receiver works differently compared to asynchronous

 

mode. If RE=1, the data is sampled on SCLK (rising or falling edge, depending on CPOL

 

and CPHA), without any oversampling. A setup and a hold time (even if the hold time is not

 

relevant due to the SPI protocol) must be respected (which depends on the baud rate: 1/16

 

bit time for an integer baud rate).

Note: 1

The UART_CK pin works in conjunction with the TX pin. When the UART transmitter is

 

disabled (TEN and REN= 0), the UART_CK and UART_TX pins go into high impedance

 

state.

2The LBCL, CPOL and CPHA bits in UART_CR3 have to be selected when both the transmitter and the receiver are disabled (TEN=REN=0) to ensure that the clock pulses function correctly. These bits should not be changed while the transmitter or the receiver is enabled.

3It is recommended to set TE and RE are set in the same instruction in order to minimize the setup and the hold time of the receiver.

4The UART supports master mode only: it cannot receive or send data related to an input clock (SCLK is always an output).

5The data given in this section apply only when the UART_DIV[3:0] bits in the UART_BRR2 register are kept at 0. Else the setup and hold times are not 1/16 of a bit time but 4/16 of a bit time.

This option allows to serially control peripherals which consist of shift registers, without losing any functions of the asynchronous communication which can still talk to other asynchronous transmitters and receivers.

Doc ID 14587 Rev 9

327/454

Universal asynchronous receiver transmitter (UART)

 

RM0016

 

 

 

 

 

 

 

 

 

Figure 122. UART example of synchronous transmission

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

RX

 

 

 

Data out

 

 

 

 

 

 

 

 

TX

 

 

 

Data in

 

 

 

 

 

 

 

 

UART

 

 

 

Synchronous device

 

 

 

 

 

 

(for example slave SPI)

 

 

 

 

 

 

 

 

 

 

SCLK

 

 

 

Clock

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Figure 123. UART data clock timing diagram (M=0)

Idle or preceding

 

Start

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Idle or next

transmission

 

 

 

 

M=0 (8 data bits)

 

 

 

 

 

 

 

 

Stop

transmission

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=0, CPHA=0)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=0, CPHA=1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=1, CPHA=0)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=1, CPHA=1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

Data

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

1

2

3

 

4

5

6

7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Start

LSB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MSB Stop

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

* LBCL bit controls last data clock pulse

Figure 124. UART data clock timing diagram (M=1)

Idle or preceding

Start

 

 

 

M=1 (9 data bits)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Idle or next

transmission

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Stop

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

transmission

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=0, CPHA=0)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=0, CPHA=1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=1, CPHA=0)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

*

 

 

 

 

 

 

 

 

 

 

 

Clock (CPOL=1, CPHA=1)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Data

 

 

 

 

 

 

 

 

 

 

 

 

 

 

8

 

 

 

 

 

 

 

 

 

 

 

 

 

 

0

1

2

3

 

4

5

6

7

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

MSB Stop

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Start

LSB

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

* LBCL bit controls last data clock pulse

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

328/454

Doc ID 14587 Rev 9

Соседние файлы в папке Минимум документации STM8_1