EasyManuals Logo

ST STM8S Reference Manual

ST STM8S
449 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #337 background imageLoading...
Page #337 background image
RM0016 Universal asynchronous receiver transmitter (UART)
Doc ID 14587 Rev 8 337/449
22.4.2 Slave mode with automatic resynchronization disabled
Note: This feature is only available in UART2 and UART3.
UART initialization
Procedure:
1. Select the desired baudrate by programming UART_BRR2 and UART_BRR1 registers,
2. Enable transmitter and receiver by setting TEN and REN bits in UART_CR2 register,
3. Enable LSLV bit in UART_CR6 register,
4. Enable LIN mode by setting LINEN bit in UART_CR3 register,
LIN Header reception
According to the LIN protocol, a slave node must wait for a valid header, coming from the
master node. Then application has to take following action, depending on the header
Identifier value:
Receive the response
Transmit the response
Ignore the response and wait for next header
When a LIN Header is received:
The LHDF flag in the UART_CR6 register indicates that a LIN Header has been
detected.
An interrupt is generated if the LHDIEN bit in the UART_CR6 register is set.
The LIN Identifier is available in the UART_DR register.
Note: It is recommended to put UART in mute mode by setting RWU bit. This mode allows
detection of headers only and prevents the reception of any other characters.
Setting the PCEN bit in the UART_CR2 register while LIN is in slave mode enables the
Identifier parity check. The PE flag in the UART_CR6 register is set together with the LHDF
flag in the UART_CR6 register if the Identifier parity is not correct.
Response transmission (slave is the publisher of the response)
In order to send n data bytes, the application must repeat following sequence n times:
1. Write data in the UART_DR register
2. Wait for the RXNE flag in the UART_SR register
3. Check for readback value by reading the UART_DR register
Once response transmission is completed, software can set the RWU bit.
Response reception (slave is the subscriber of the response)
In order to receive n data bytes, the application must repeat following sequence n times:
1. Wait for the RXNE flag in the UART_SR register
2. Read the UART_DR register
Once response reception is completed, software can set the RWU bit.

Table of Contents

Other manuals for ST STM8S

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the ST STM8S and is the answer not in the manual?

ST STM8S Specifications

General IconGeneral
BrandST
ModelSTM8S
CategoryMicrocontrollers
LanguageEnglish

Related product manuals