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.