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

RM0016

Universal asynchronous receiver transmitter (UART)

 

 

22.7UART registers

22.7.1Status register (UART_SR)

Address offset: 0x00

Reset value: 0xC0

7

6

5

4

3

2

1

0

 

 

 

 

 

 

 

 

TXE

TC

RXNE

IDLE

OR/LHE

NF

FE

PE

 

 

 

 

 

 

 

 

r

rc_w0

rc_w0

r

r

r

r

r

 

 

 

 

 

 

 

 

Bit 7 TXE: Transmit data register empty

This bit is set by hardware when the content of the TDR register has been transferred into the shift register. An interrupt is generated if the TIEN bit =1 in the UART_CR2 register. It is cleared by a write to the UART_DR register.

0:Data is not transferred to the shift register

1:Data is transferred to the shift register

Bit 6 TC: Transmission complete

This bit is set by hardware if the transmission of a frame containing data is complete and TXE bit is set. An interrupt is generated if TCIEN=1 in the UART_CR2 register. The TC bit is cleared either by a software sequence (a read to the UART_SR register followed by a write to the UART_DR register), or by programming the bit to ‘0’. This clear sequence is recommended only for multibuffer communications.

0:Transmission is not complete

1:Transmission is complete

Bit 5 RXNE: Read data register not empty

This bit is set by hardware when the content of the RDR shift register has been transferred to the UART_DR register. An interrupt is generated if RIEN=1 in the UART_CR2 register. It is cleared by a read to the UART_DR register. In UART2 and UART3, it can also be cleared by writing 0.

0:Data is not received

1:Received data is ready to be read.

Bit 4 IDLE: IDLE line detected (1)

This bit is set by hardware when an Idle Line is detected. An interrupt is generated if the ILIEN=1 in the UART_CR2 register. It is cleared by a software sequence (a read to the UART_SR register followed by a read to the UART_DR register).

0:No Idle Line is detected

1:Idle Line is detected

Doc ID 14587 Rev 9

349/454

Universal asynchronous receiver transmitter (UART)

RM0016

 

 

Bit 3 OR: Overrun error(2)

This bit is set by hardware when the word currently being received in the shift register is ready to be transferred into the RDR register while RXNE=1. An interrupt is generated if RIEN=1 in the UART_CR2 register. It is cleared by a software sequence (a read to the UART_SR register followed by a read to the UART_DR register).

0:No Overrun error

1:Overrun error is detected

LHE LIN Header Error (LIN slave mode)

During LIN Header reception, this bit signals three error types:

Break delimiter too short

Synch Field error

Deviation error (if LASE=1)

Identifier framing error

0:No LIN Header error

1:LIN Header error detected

Bit 2 NF: Noise flag (3)

This bit is set by hardware when noise is detected on a received frame. It is cleared by a software sequence (a read to the UART_SR register followed by a read to the UART_DR register).

0:No noise is detected

1:Noise is detected

Bit 1 FE: Framing error (4)

This bit is set by hardware when a de-synchronization, excessive noise or a break character is detected. It is cleared by a software sequence (a read to the UART_SR register followed by a read to the UART_DR register).

0:No Framing error is detected

1:Framing error or break character is detected

Note: For the UART2 and UART3, in LIN slave mode (bits LINE and LSLV are set), when a framing error is detected in the Synch or Identifier Fields , the FE bit is set. But the FE bit will not be set when a Break reception is detected.

Bit 0 PE: Parity error

This bit is set by hardware when a parity error occurs in receiver mode. It is cleared by a software sequence (a read to the status register followed by a read to the UART_DR data register). You have to wait for the RXNE flag to be set before clearing it. An interrupt is generated if PIEN=1 in the UART_CR1 register.

0:No parity error

1:Parity error (or, in LIN slave mode, identifier parity error)

1.The IDLE bit will not be set again until the RXNE bit has been set itself (i.e. a new idle line occurs)

2.When this bit is set, the RDR register content will not be lost but the shift register will be overwritten.

3.This bit does not generate interrupt as it appears at the same time as the RXNE bit which itself generates an interrupt.

4.This bit does not generate interrupt as it appears at the same time as the RXNE bit which itself generates an interrupt. If the word currently being transferred causes both frame error and overrun error, it will be transferred and only the OR bit will be set.

350/454

Doc ID 14587 Rev 9

RM0016

Universal asynchronous receiver transmitter (UART)

 

 

22.7.2Data register (UART_DR)

Address offset: 0x01

Reset value: 0xXX

7

6

5

4

3

2

1

0

 

 

 

 

 

 

 

 

 

 

 

 

DR[7:0]

 

 

 

 

 

 

 

 

 

 

 

 

rw

rw

rw

rw

 

rw

rw

rw

rw

 

 

 

 

 

 

 

 

 

Bits 7:0 DR[7:0]: Data value

Contains the Received or Transmitted data character, depending on whether it is read from or written to.

The Data register performs a double function (read and write) since it is composed of two registers, one for transmission (TDR) and one for reception (RDR)

The TDR register provides the parallel interface between the internal bus and the output shift register.

The RDR register provides the parallel interface between the input shift register and the internal bus.

22.7.3Baud rate register 1 (UART_BRR1)

The Baud Rate Registers are common to both the transmitter and the receiver. The baud rate is programmed using two registers BRR1 and BRR2. Writing of BRR2 (if required) should precede BRR1, since a write to BRR1 will update the baud counters.

See Figure 119: How to code UART_DIV in the BRR registers on page 322 and Table 54: Baud rate programming and error calculation on page 323

Note: 1 The baud counters stop counting if the TEN or REN bits are disabled respectively.

Address offset: 0x02

Reset value: 0x00

7

6

5

4

 

3

2

1

0

 

 

 

 

 

 

 

 

 

 

 

UART_DIV[11:4]

 

 

 

 

 

 

 

 

 

 

 

 

 

rw

rw

rw

rw

 

-

rw

rw

rw

 

 

 

 

 

 

 

 

 

Bits 7:0 UART_DIV[11:4] UART_DIV bits (1)

These 8 bits define the 2nd and 3rd nibbles of the 16-bit UART divider (UART_DIV).

1. BRR1 = 00h means UART clock is disabled.

Doc ID 14587 Rev 9

351/454

Universal asynchronous receiver transmitter (UART)

RM0016

 

 

22.7.4Baud rate register 2 (UART_BRR2)

Address offset: 0x03

Reset value: 0x00

7

6

5

4

3

2

1

0

 

 

 

 

 

 

 

 

 

UART_DIV[15:12]

 

 

 

UART_DIV[3:0]

 

 

 

 

 

 

 

 

 

 

rw

rw

rw

rw

rw

rw

 

rw

rw

 

 

 

 

 

 

 

 

 

Bits 7:4 UART_DIV[15:12] MSB of UART_DIV.

These 4 bits define the MSB of the UART Divider (UART_DIV)

Bits 3:0 UART_DIV[3:0]: LSB of UART_DIV.

These 4 bits define the LSB of the UART Divider (UART_DIV)

22.7.5Control register 1 (UART_CR1)

Address offset: 0x04

Reset value: 0x00

7

6

5

4

3

2

1

0

 

 

 

 

 

 

 

 

R8

T8

UARTD

M

WAKE

PCEN

PS

PIEN

 

 

 

 

 

 

 

 

rw

rw

rw

rw

rw

rw

rw

rw

 

 

 

 

 

 

 

 

Bit 7 R8: Receive Data bit 8.

This bit is used to store the 9th bit of the received word when M=1

Bit 6 T8: Transmit data bit 8.

This bit is used to store the 9th bit of the transmitted word when M=1

Bit 5 UARTD: UART Disable (for low power consumption).

When this bit is set the UART prescaler and outputs are stopped at the end of the current byte transfer in order to reduce power consumption. This bit is set and cleared by software.

0:UART enabled

1:UART prescaler and outputs disabled

Bit 4 M: word length.

This bit determines the word length. It is set or cleared by software.

0:1 Start bit, 8 Data bits, n Stop bit (n depending on STOP[1:0] bits in the UART_CR3 register)

1:1 Start bit, 9 Data bits, 1 Stop bit

Note: The M bit must not be modified during a data transfer (both transmission and reception) In LIN slave mode, the M bit and the STOP[1:0] bits in the UART_CR3 register should be kept at 0.

Bit 3 WAKE: Wakeup method.

This bit determines the UART wakeup method, it is set or cleared by software.

0:Idle Line

1:Address Mark

352/454

Doc ID 14587 Rev 9

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