23. Universal Asynchronous Receiver Transmitter (LPUART)

23.1 LPUART introduction

The low-power universal asynchronous receiver transmitter (LPUART) is a UART that allows bidirectional UART communications with a limited power consumption. Only 32.768 kHz LSE clock is required to allow UART communications up to 9600 baud/s. Higher baud rates can be reached when the LPUART is clocked by clock sources different from the LSE clock.

Even when the microcontroller is in Deepstop mode, the LPUART can wait for an incoming UART frame while having an extremely low energy consumption. The LPUART includes all the necessary hardware support to make asynchronous serial communications possible with minimum power consumption.

It supports half-duplex single wire communications and modem operations (CTS/RTS).

It also supports multiprocessor communications.

DMA (direct memory access) can be used for data transmission/reception.

23.2 LPUART main features

23.3 LPUART functional description

Any LPUART bidirectional communication requires a minimum of two pins: Receive Data In (RX) and Transmit Data Out (TX):

Through these pins, serial data are transmitted and received in normal LPUART mode as frames comprising:

Refer to Section 23.5: LPUART registers for the definitions of each bit. The following pins are required in RS232 hardware flow control mode:

The following pin is required in RS485 hardware control mode:

Note: DE and nRTS share the same pin.

Figure 149. LPUART block diagram

LPUART block diagram showing internal architecture, clock domains, and external pins.

The diagram illustrates the internal architecture of the LPUART block, divided into two main clock domains: LPUART_pclk (peripheral clock) and LPUART_ker_ck (kernel clock).

LPUART block diagram showing internal architecture, clock domains, and external pins.

The simplified block diagram given in Figure 149 shows two fully independent clock domains:

There is no constraint between lpuart_pclk and lpuart_ker_ck: lpuart_ker_ck can be faster or slower than lpuart_pclk, with no more limitation than the ability for the software to manage the communication fast enough.

23.3.1 LPUART character description

Word length may be selected as being either 7 or 8 or 9 bits by programming the M bits (M0: bit 12 and M1: bit 28) in the LPUART_CR1 register (see Figure 125. Word length programming ).

In default configuration, the signal (TX or RX) is in low state during the start bit. It is in high state during the stop bit.

These values can be inverted, separately for each signal, through polarity configuration control.

An Idle character is interpreted as an entire frame of “1”s. (The number of “1”s includes the number of stop bits).

A break character is interpreted on receiving “0”s for a frame period. At the end of the break frame, the transmitter inserts 2 stop bits.

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.

The details of each block is given below.

Figure 150. LPUART word length programming

Timing diagrams for 9-bit, 8-bit, and 7-bit word lengths showing data frames, idle frames, and break frames relative to a clock signal.

The diagram illustrates the timing for three different word lengths in LPUART, showing the relationship between the data frame, idle frame, and break frame relative to a clock signal.

9-bit word length (M = 01 ), 1 Stop bit

The data frame consists of a Start bit, 9 data bits (Bit0 to Bit8), a Possible Parity bit, and a Stop bit. The clock signal is shown as a series of pulses. The last data clock pulse is controlled by the LBCL bit (marked with **). The Idle frame is a continuous high level. The Break frame consists of two Stop bits followed by a Start bit.

8-bit word length (M = 00 ), 1 Stop bit

The data frame consists of a Start bit, 8 data bits (Bit0 to Bit7), a Possible Parity bit, and a Stop bit. The clock signal is shown as a series of pulses. The last data clock pulse is controlled by the LBCL bit (marked with **). The Idle frame is a continuous high level. The Break frame consists of two Stop bits followed by a Start bit.

7-bit word length (M = 10 ), 1 Stop bit

The data frame consists of a Start bit, 7 data bits (Bit0 to Bit6), a Possible Parity bit, and a Stop bit. The clock signal is shown as a series of pulses. The last data clock pulse is controlled by the LBCL bit (marked with **). The Idle frame is a continuous high level. The Break frame consists of two Stop bits followed by a Start bit.

** LBCL bit controls last data clock pulse

Timing diagrams for 9-bit, 8-bit, and 7-bit word lengths showing data frames, idle frames, and break frames relative to a clock signal.

23.3.2 FIFOs and thresholds

The LPUART can operate in FIFO mode, with the FIFO buffers having a depth of 16 bytes. The LPUART comes with a transmit FIFO (TXFIFO) and a receive FIFO (RXFIFO). The FIFO mode is enabled by setting the bit 29 FIFOEN in the USARTx_CR1 register.

Being 9 bits the maximum data word length, the TXFIFO is 9-bits wide. However the RXFIFO is by default 12-bits wide. This is due to the fact that the receiver does not only put the data in the FIFO, but also the error flags associated to each character (Parity error, Noise error and Framing error flags).

Note: The received data is stored in the RXFIFO with its flags. But if RDR is read, just the data is read. The status flags are available in the LPUART_ISR register.

It is possible to define the TXFIFO and RXFIFO levels at which the Tx and RX interrupt are triggered. These thresholds are programmed through bit fields RXFTCFG and TXFTCFG in the LPUART_CR3 control register.

In this case:

RXFIFO threshold

The RXFIFO threshold is configured using the RXFTCFG bit fields in the LPUART_CR3 register.

When the number of received data is equal to the programmed RXFTCFG, the flag RXFT in the LPUART_ISR register is set.

Having RXFT flag set means that there are RXFTCFG data received: 1 data in LPUART_RDR and (RXFTCFG - 1) data in the RXFIFO. So, when the RXFTCFG is programmed to «101», the RXFT flag is set when 16 data are received: 15 data in the RXFIFO and 1 data in the LPUART_RDR. Consequently, the 17th received data does not set the overrun flag.

23.3.3

Transmitter

The transmitter can send data words of either 7 or 8 or 9 bits depending on the M bit status. The transmit enable bit (TE) must be set in order to activate the transmitter function. The data in the transmit shift register is output on the TX pin.

Character transmission

During an LPUART transmission, data shifts out least significant bit first (default configuration) on the TX pin. In this mode, the LPUART_TDR register consists of a buffer (TDR) between the internal bus and the transmit shift register (see Figure 149. LPUART block diagram).

When FIFO mode is enabled, data written to the LPUART_TDR register is queued in the TXFIFO.

Every character is preceded by a start bit which is a logic level low for one bit period. The character is terminated by a configurable number of stop bits.

The following stop bits are supported by LPUART: 1 and 2 stop bits.

Note: The TE bit must be set before writing the data to be transmitted to the LPUART_TDR.

Note: The TE bit should not be reset during transmission of data. Resetting the TE bit during the transmission corrupts the data on the TX pin as the baud rate counters get frozen. The current data being transmitted is lost. An idle frame is sent after the TE bit is enabled.

Configurable stop bits

The number of stop bits to be transmitted with every character can be programmed in control register 2, bits 13,12.

A break transmission is 10 low bits (when M[1:0] = 00) or 11 low bits (when M[1:0] = 01) or 9 low bits (when M[1:0] = 10) followed by 2 stop bits. It is not possible to transmit long breaks (break of length greater than 9/10/11 low bits).

Figure 151. Configurable stop bits

Timing diagrams for 8-bit data with 1, 1.5, and 2 stop bits. Each diagram shows the sequence of bits: Start bit, 8 data bits (Bit0-Bit7), Possible parity bit, Stop bits (1, 1.5, or 2), and the start of the next data frame. A CLOCK signal is shown below the bits. A note indicates that the LBCL bit controls the last data clock pulse.

The diagram illustrates three timing scenarios for 8-bit data transmission:

Timing diagrams for 8-bit data with 1, 1.5, and 2 stop bits. Each diagram shows the sequence of bits: Start bit, 8 data bits (Bit0-Bit7), Possible parity bit, Stop bits (1, 1.5, or 2), and the start of the next data frame. A CLOCK signal is shown below the bits. A note indicates that the LBCL bit controls the last data clock pulse.

Character transmission procedure

  1. 1. Program the M bits in LPUART_CR1 to define the word length.
  2. 2. Select the desired baud rate using the LPUART_BRR register.
  3. 3. Program the number of stop bits in LPUART_CR2.
  4. 4. Enable the LPUART by writing the UE bit in the LPUART_CR1 register to 1.
  5. 5. Select DMA enable (DMAT) in LPUART_CR3 if multi-buffer communication is to take place. Configure the DMA register as explained in Section 23.3.6: Multiprocessor communication .
  6. 6. Set the TE bit in LPUART_CR1 to send an idle frame as first transmission.
  7. 7. Write the data to send in the LPUART_TDR register. Repeat this for each data to be transmitted in case of single buffer.
    • – When FIFO mode is disabled, writing a data in the LPUART_TDR clears the TXE flag.
    • – When FIFO mode is enabled, writing a data in the LPUART_TDR adds one data to the TXFIFO and write operations in the LPUART_TDR are made when TXFNF flag is set. This flag remains set until the TXFIFO is full.
  8. 8. After writing the last data into the LPUART_TDR register, wait until TC=1. This indicates that the transmission of the last frame is complete. This is required for instance when the LPUART is disabled or enters the Halt mode to avoid corrupting the last transmission.
    • – When FIFO mode is disabled, this indicates that the transmission of the last frame is complete.
    • – When FIFO mode is enabled, this indicates that both TXFIFO and shift register are empty.

Single byte communication

Clearing the TXE bit is always performed by a write to the transmit data register. The TXE flag is set by hardware and it indicates:

This flag generates an interrupt if the TXEIE bit is set.

When a transmission is taking place, a write instruction to the LPUART_TDR register stores the data in the TDR register and is copied in the shift register at the end of the current transmission.

When no transmission is taking place, a write instruction to the LPUART_TDR register places the data in the shift register, the data transmission starts, and the TXE bit is set.

When the TXFIFO is not full, the TXFNF flag stays at 1 even after a write in LPUART_TDR. It is cleared when the TXFIFO is full. This flag generates an interrupt if TXFNEIE bit is set.

Alternatively, interrupts can be generated and data can be written into TXFIFO when the TXFIFO threshold is reached. In this case, the CPU can write a block of data defined by the programmed threshold.

If a frame is transmitted (after the stop bit) and the TXE flag (TXFE in case of FIFO mode) is set, the TC bit goes high. An interrupt is generated if the TCIE bit is set in the LPUART_CR1 register.

After writing the last data in the LPUART_TDR register, it is mandatory to wait for TC=1 before disabling the LPUART or causing the microcontroller to enter the low-power mode (see Figure 152. TC/TXE behavior when transmitting).

Figure 152. TC/TXE behavior when transmitting

Timing diagram showing TX line, TXE flag, LPUART_DR, and TC flag for three frames (Frame 1, Frame 2, Frame 3).

The diagram illustrates the timing of the TX line, TXE flag, LPUART_DR register, and TC flag during the transmission of three frames (Frame 1, Frame 2, and Frame 3) following an idle preamble.

Software flow:

Timing diagram showing TX line, TXE flag, LPUART_DR, and TC flag for three frames (Frame 1, Frame 2, Frame 3).

Note: When FIFO management is enabled, the TXFNF flag is used for data transmission.

Break characters

Setting the SBKRQ bit transmits a break character. The break frame length depends on the M bits (see Figure 120. Bus transfer diagrams for SMBus target receiver (SBC=1)).

If a '1' is written to the SBKRQ bit, a break character is sent on the TX line after completing the current character transmission. The SBKF bit is set by the write operation and it is reset by hardware when the break character is completed (during the stop bits after the break character). The LPUART inserts a logic 1 signal (STOP) for the duration of 2 bits at the end of the break frame to guarantee the recognition of the start bit of the next frame.

When the SBKRQ bit is set, the break character is sent at the end of the current transmission.

When FIFO mode is enabled, sending the break character has priority on sending data even if the TXFIFO is full.

Idle characters

Setting the TE bit drives the LPUART to send an idle frame before the first data frame.

23.3.4 Receiver

Receiver

The LPUART can receive data words of either 7 or 8 or 9 bits depending on the M bits in the LPUART_CR1 register.

Start bit detection

In LPUART, for START bit detection, a falling edge should be detected first on the Rx line, then a sample is taken in the middle of the start bit to confirm that it is still '0'. If the start sample is at '1', then the noise error flag (NF) is set, then the START bit is discarded and the receiver waits for a new START bit. Otherwise, the receiver continues to sample all incoming bits normally.

Character reception

During an LPUART reception, data shifts in least significant bit first (default configuration) through the RX pin. In this mode, the LPUART_RDR register consists of a buffer (RDR) between the internal bus and the received shift register.

Character reception procedure

  1. 1. Program the M bits in LPUART_CR1 to define the word length.
  2. 2. Select the desired baud rate using the baud rate register LPUART_BRR.
  3. 3. Program the number of stop bits in LPUART_CR2.
  4. 4. Enable the LPUART by writing the UE bit in the LPUART_CR1 register to 1.
  5. 5. Select DMA enable (DMAR) in LPUART_CR3 if multi-buffer communication is to take place. Configure the DMA register as explained in Section 23.3.6: Multiprocessor communication .
  6. 6. Set the RE bit LPUART_CR1. This enables the receiver which begins searching for a start bit.

When a character is received:

Break character

When a break character is received, the LPUART handles it as a framing error.

Idle character

When an idle frame is detected, the procedure is the same as for a received data character plus an interrupt if the IDLEIE bit is set.

Overrun error

The ORE bit is reset by setting the ORECF bit in the ICR register.

Note: The ORE bit, when set, indicates that at least 1 data has been lost.

Note: When the FIFO mode is disabled, there are two possibilities.

Selecting the clock source

The choice of the clock source is done through the clock control system (see Section 6: Reset and clock controller (RCC) ). The clock source must be chosen before enabling the LPUART (by setting the UE bit).

The choice of the clock source must be done according to two criteria:

The clock source frequency is lpuart_kern_ck.

When the dual clock domain and the wakeup from Deepstop mode features are supported, the lpuart_kern_ck clock source can be selected through Section 6: Reset and clock controller (RCC) . The lpuart_kern_ck can be divided by a programmable factor in the LPUARTx_PRESC register.

Figure 153. lpuart_ker_ck clock divider block diagram

Block diagram of the lpuart_ker_ck clock divider. An input signal 'lpuart_ker_ck' enters a large grey box. Inside the box, the signal first passes through a block labeled 'LPUARTx_PRESC[3:0]'. The output of this block is labeled 'lpuart_ker_ck_pres' and it enters a second block labeled 'LPUARTx_BRR register and oversampling'.
graph LR
    subgraph ClockDivider [ ]
        direction LR
        A[LPUARTx_PRESC[3:0]] -- lpuart_ker_ck_pres --> B[LPUARTx_BRR register and oversampling]
    end
    lpuart_ker_ck --> A
    style ClockDivider fill:none,stroke:none
    style lpuart_ker_ck fill:none,stroke:none
  
Block diagram of the lpuart_ker_ck clock divider. An input signal 'lpuart_ker_ck' enters a large grey box. Inside the box, the signal first passes through a block labeled 'LPUARTx_PRESC[3:0]'. The output of this block is labeled 'lpuart_ker_ck_pres' and it enters a second block labeled 'LPUARTx_BRR register and oversampling'.

Choosing lpuart_kern_ck as LSE clock source may allow the LPUART to receive data while the MCU is in low-power mode. Depending on the received data and wakeup mode selection, the LPUART wakes up the MCU, when needed, in order to transfer the received data by software reading the LPUART_RDR register or by DMA. For the other clock sources, the system must be active in order to allow LPUART communication.

When the LPUART clock source is configured to be LSE, it is possible to keep enabled this clock during Deepstop mode by setting the UCESM bit in the LPUART_CR3 control register.

The communication speed range (specially the maximum communication speed) is also determined by the clock source.

The receiver samples each incoming baud as close as possible to the middle of the baud-period. Only a single sample is taken of each of the incoming bauds.

Note: There is no noise detection for data.

Framing error

A framing error is detected when the stop bit is not recognized on reception at the expected time, following either a de-synchronization or excessive noise.

When the framing error is detected:

The FE bit is reset by writing 1 to the FECF in the LPUART_ICR register.

Configurable stop bits during reception

The number of stop bits to be received can be configured through the LPUART_CR2 register control bits: it can be either 1 or 2 in normal mode.

23.3.5 Baud rate generation

The baud rate for the receiver and transmitter (Rx and Tx) are both set to the same value as programmed in the LPUART_BRR register.

\[ Tx/Rxbaud = \frac{256 \times f_{CKPRES}}{LPUARTDIV} \quad (7) \]

LPUARTDIV is coded on the LPUART_BRR register.

Note: The baud counters are updated to the new value in the baud registers after a write operation to LPUART_BRR. Hence the baud rate register value should not be changed during communication. It is forbidden to write values less than 0x300 in the LPUART_BRR register. f CK must be in the range (3 x baud rate) to (4096 x baud rate).

Table 104. Error calculation for programmed baud rates at f ck =32.768 KHz

Baud ratef ck =32.768 kHz
S.NoDesiredActualValue programmed in the baud rate register% Error = (calculated - desired) B.rate / desired B.rate
1300 Bps300 Bps0x6D3A0
2600 Bps600 Bps0x369D0
31200 Bps1200.087 Bps0x1B4E0.007
42400 Bps2400.17 Bps0xDA70.007
54800 Bps4801.72 Bps0x6D30.035
69600 Bps9608.94 Bps0x3690.093

Table 105. Error calculation for programmed baudrates at \( f_{ck}=16 \) MHz

Baud rate\( f_{ck}=16 \) MHz
S.NoDesiredActualValue programmed in the baud rate register% Error = (calculated - desired) B.rate / desired B.rate
19.6 kBps9.60001 kBps0x682AA0
219.2 kBps19.20003 kBps0x341550
338.4 kBps38.40024 kBps0x1A0AA0
457.6 kBps57.60009 kBps0x115C70
5115.2 kBps115.2018 kBps0x8AE30.001
6230.4 kBps230.41008 kBps0x45710.004
7460.8 kBps460.84608 kBps0x22B80.01
8921.6 kBps921.69216 kBps0x115C0.01
91843.2 kBps1843.38433 kBps0x8AE0.01
103686.4 kBps3686.76867 kBps0x4570.01

23.3.6 Multiprocessor communication

It is possible to perform multiprocessor communication with the LPUART (with several LPUARTs connected in a network). For instance one of the LPUARTs can be the master, its TX output connected to the RX inputs of the other LPUARTs. The others are slaves, their respective TX outputs are logically ANDed together and connected to the RX input of the master.

In multiprocessor configurations it is often desirable that only the intended message recipient should actively receive the full message contents, thus reducing redundant LPUART service overhead for all non addressed receivers.

The non addressed devices may be placed in mute mode by means of the muting function. In order to use the mute mode feature, the MME bit must be set in the LPUART_CR1 register.

Note: When FIFO management is enabled and MME is already set, MME bit must not be cleared and then set again quickly (within two UCLK cycles), otherwise mute mode might remain active.

In mute mode:

The LPUART can enter or exit from mute mode using one of two methods, depending on the WAKE bit in the LPUART_CR1 register:

Idle line detection (WAKE=0)

The LPUART enters mute mode when the MMRQ bit is written to 1 and the RWU is automatically set.

It wakes up when an Idle frame is detected. Then the RWU bit is cleared by hardware but the IDLE bit is not set in the LPUART_ISR register. An example of mute mode behavior using Idle line detection is given in Figure 154. Mute mode using idle line detection.

Figure 154. Mute mode using idle line detection

Timing diagram for Figure 154 showing RX and RWU signals. RX line shows Data 1-4, IDLE, Data 5, Data 6. RWU line goes high when MMRQ is written to 1, stays high through the IDLE period, and goes low when an idle frame is detected. RX(F)NE flags are shown rising after Data 5 and Data 6.
Timing diagram for Figure 154 showing RX and RWU signals. RX line shows Data 1-4, IDLE, Data 5, Data 6. RWU line goes high when MMRQ is written to 1, stays high through the IDLE period, and goes low when an idle frame is detected. RX(F)NE flags are shown rising after Data 5 and Data 6.

Note: If the MMRQ is set while the IDLE character has already elapsed, mute mode is not entered (RWU is not set). If the LPUART is activated while the line is IDLE, the idle state is detected after the duration of one IDLE frame (not only after the reception of one character frame).

4-bit/7-bit address mark detection (WAKE=1)

In this mode, bytes are recognized as addresses if their MSB is a '1', otherwise they are considered as data. In an address byte, the address of the targeted receiver is put in the 4 or 7 LSBs. The choice of 7 or 4 bit address detection is done using the ADDM7 bit. This 4-bit/7-bit word is compared by the receiver with its own address which is programmed in the ADD bits in the LPUART_CR2 register.

Note: In 7-bit and 9-bit data modes, address detection is done on 6-bit and 8-bit addresses (ADD[5:0] and ADD[7:0]) respectively.

The LPUART enters mute mode when an address character is received which does not match its programmed address. In this case, the RWU bit is set by hardware. The RXNE flag is not set for this address byte and no interrupt or DMA request is issued when the LPUART enters mute mode.

The LPUART also enters mute mode when the MMRQ bit is written to 1. The RWU bit is also automatically set in this case.

The LPUART exits from mute mode when an address character is received which matches the programmed address. Then the RWU bit is cleared and subsequent bytes are received normally. The RXNE/RXFNE bit is set for the address character since the RWU bit has been cleared.

Note: When FIFO management is enabled, when MMRQ bit is set while the receiver is sampling the last bit of a data; this data may be received before effectively entering in mute mode.

An example of mute mode behavior using address mark detection is given in Figure 155. Mute mode using address mark detection.

Figure 155. Mute mode using address mark detection

In this example, the current address of the receiver is 1 (programmed in the LPUART_CR2 register)

Timing diagram for Figure 155. RX line shows IDLE, Addr=0 (non-matching), Data 1, Data 2, IDLE, Addr=1 (matching), Data 3, Data 4, Addr=2 (non-matching), Data 5. RWU line goes high when Addr=0 is received (MMRQ=1, RXNE cleared), goes low when Addr=1 is received (matching), and goes high again when Addr=2 is received (non-matching). RXNE flags are shown rising for the matching address (Addr=1) and the subsequent data bytes.
Timing diagram for Figure 155. RX line shows IDLE, Addr=0 (non-matching), Data 1, Data 2, IDLE, Addr=1 (matching), Data 3, Data 4, Addr=2 (non-matching), Data 5. RWU line goes high when Addr=0 is received (MMRQ=1, RXNE cleared), goes low when Addr=1 is received (matching), and goes high again when Addr=2 is received (non-matching). RXNE flags are shown rising for the matching address (Addr=1) and the subsequent data bytes.

23.3.7 Parity control

Parity control (generation of parity bit in transmission and parity checking in reception) can be enabled by setting the PCE bit in the LPUART_CR1 register. Depending on the frame length defined by the M bits, the possible LPUART frame formats are as listed in Table 106. Frame formats .

Table 106. Frame formats

M bitsPCE bitLPUART frame (1)(2)
000| SB | 8-bit data | STB |
001| SB | 7-bit data | PB | STB |
010| SB | 9-bit data | STB |
011| SB | 8-bit data PB | STB |
100| SB | 7-bit data | STB |
101| SB | 6-bit data | PB | STB |

1. Legends: SB: start bit, STB: stop bit, PB: parity bit. In the data register the PB is always taking the MSB position (8 th or 7 th , depending on the M bit value).

2. In the data register, the PB is always taking the MSB position (8 th or 7 th , depending on the M bit value).

Even parity

The parity bit is calculated to obtain an even number of “1’s inside the frame, which is made of the 6, 7 or 8 LSB bits (depending on M bit values) and the parity bit.

As an example, if data=00110101, and 4 bits are set, then the parity bit is 0 if even parity is selected (PS bit in LPUART_CR1 = 0).

Odd parity

The parity bit is calculated to obtain an odd number of “1’s inside the frame made of the 6, 7 or 8 LSB bits (depending on M bit values) and the parity bit.

As an example, if data=00110101 and 4 bits set, then the parity bit is 1 if odd parity is selected (PS bit in LPUART_CR1 = 1).

Parity checking in reception

If the parity check fails, the PE flag is set in the LPUART_ISR register and an interrupt is generated if PEIE is set in the LPUART_CR1 register. The PE flag is cleared by software writing 1 to the PECF in the LPUART_ICR register.

Parity generation in transmission

If the PCE bit is set in LPUART_CR1 , then the MSB bit of the data written in the data register is transmitted but is changed by the parity bit (even number of “1’s if even parity is selected (PS=0) or an odd number of “1’s if odd parity is selected (PS=1)).

23.3.8 Single-wire half-duplex communication

Single-wire half-duplex mode is selected by setting the HDSEL bit in the LPUART_CR3 register.

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

The LPUART can be configured to follow a single-wire half-duplex protocol where the TX and RX lines are internally connected. The selection between half- and full-duplex communication is made with a control bit HDSEL in LPUART_CR3 .

As soon as HDSEL is written to 1:

Apart from this, the communication protocol is similar to normal LPUART mode. Any conflicts on the line must be managed by software (by the use of a centralized arbiter, for instance). In particular, the transmission is never blocked by hardware and continues as soon as data is written in the data register while the TE bit is set.

Note: In LPUART, in the case of 1-STOP bit configuration, the RXNE flag is set in the middle of the STOP bit.

23.3.9 Continuous communication using DMA

The LPUART is capable of performing continuous communication using the DMA. The DMA requests for Rx buffer and Tx buffer are generated independently.

Note: Refer to Section 22.4: USART implementation to determine if the DMA mode is supported. If DMA is not supported, use the LPUART as explained in Section 23.3.4: Receiver to perform continuous communication. When FIFO is disabled, the TXE/ RXNE flags in the LPUART_ISR register can be cleared.

Transmission using DMA

DMA mode can be enabled for transmission by setting DMAT bit in the LPUART_CR3 register. Data is loaded from an SRAM area configured using the DMA peripheral, see Section 10: DMA controller (DMA), to the LPUART_TDR register whenever the TXE flag (TXFNF flag if FIFO mode is enabled) is set. To map a DMA channel for LPUART transmission, use the following procedure (x denotes the channel number):

  1. 1. Write the LPUART_TDR register address in the DMA control register to configure it as the destination of the transfer. The data is moved to this address from memory after each TXE (or TXFNF if FIFO mode is enabled) event.
  2. 2. Write the memory address in the DMA control register to configure it as the source of the transfer. The data is loaded into the LPUART_TDR register from this memory area after each TXE (or TXFNF if FIFO mode is enabled) event.
  3. 3. Configure the total number of bytes to be transferred to the DMA control register.
  4. 4. Configure the channel priority in the DMA register.
  5. 5. Configure DMA interrupt generation after half/full transfer as required by the application.
  6. 6. Clear the TC flag in the LPUART_ISR register by setting the TCCF bit in the LPUART_ICR register.
  7. 7. Activate the channel in the DMA register.

When the number of data transfers programmed in the DMA controller is reached, the DMA controller generates an interrupt on the DMA channel interrupt vector.

In transmission mode, once the DMA has written all the data to be transmitted (the TCIF flag is set in the DMA_ISR register), the TC flag can be monitored to make sure that the LPUART communication is complete. This is required to avoid corrupting the last transmission before disabling the LPUART or entering Deepstop mode. Software must wait until TC=1. The TC flag remains cleared during all data transfers and it is set by hardware at the end of transmission of the last frame.

Figure 156. Transmission using DMA

Timing diagram for Figure 156. Transmission using DMA. The diagram shows the relationship between the TX line, TXE flag, DMA request, USART_DR, TC flag, DMA writes USART_DR, and DMA TCIF flag over time for three frames (Frame 1, Frame 2, Frame 3).

The diagram illustrates the timing for DMA transmission of three frames (F1, F2, F3) over an IDLE preamble. The signals shown are:

Software flow: Software configures DMA to send 3 data blocks and enables USART. DMA writes F1 into USART_DR, F2 into USART_DR, and F3 into USART_DR. The DMA transfer is complete (TCIF=1 in DMA_ISR). Software waits until TC=1.

Timing diagram for Figure 156. Transmission using DMA. The diagram shows the relationship between the TX line, TXE flag, DMA request, USART_DR, TC flag, DMA writes USART_DR, and DMA TCIF flag over time for three frames (Frame 1, Frame 2, Frame 3).

Note: When FIFO management is enabled, the DMA request is triggered by transmit FIFO not full (i.e. TXFNF = 1).

Reception using DMA

DMA mode can be enabled for reception by setting the DMAR bit in the LPUART_CR3 register. Data is loaded from the LPUART_RDR register to an SRAM area configured using the DMA peripheral, refer to Section 10: DMA controller (DMA) whenever a data byte is received. To map a DMA channel for LPUART reception, use the following procedure:

  1. 1. Write the LPUART_RDR register address in the DMA control register to configure it as the source of the transfer. The data is moved from this address to the memory after each RXNE (RXFNE in case FIFO mode is enabled) event.
  2. 2. Write the memory address in the DMA control register to configure it as the destination of the transfer. The data is loaded from LPUART_RDR to this memory area after each RXNE (RXFNE in case FIFO mode is enabled) event.
  3. 3. Configure the total number of bytes to be transferred to the DMA control register.
  4. 4. Configure the channel priority in the DMA control register.
  5. 5. Configure interrupt generation after half/full transfer as required by the application.
  6. 6. Activate the channel in the DMA control register.

When the number of data transfers programmed in the DMA controller is reached, the DMA controller generates an interrupt on the DMA channel interrupt vector.

Figure 157. Reception using DMA

Timing diagram for reception using DMA showing three frames (Frame 1, Frame 2, Frame 3) being received. The diagram tracks the TX line, RXNE flag, DMA request, USART_DR register, DMA reads, and DMA TCIF flag. Callouts explain the sequence: software configures DMA for 3 blocks, DMA reads F1, F2, and F3 from USART_DR, and finally the transfer is complete when TCIF=1.

The diagram illustrates the timing for receiving three frames (Frame 1, Frame 2, Frame 3) using DMA. The top row shows the TX line with data blocks for each frame. Below it, the RXNE flag is shown pulsing high when a frame is received and returning low when it is cleared by a DMA read (labeled 'Set by hardware cleared by DMA read'). The DMA request line follows the RXNE flag. The USART_DR register contains the data blocks F1, F2, and F3. The 'DMA reads USART_DR' line shows pulses corresponding to the reading of each frame. The bottom row shows the DMA TCIF flag (transfer complete), which is set by hardware when the third frame (F3) is read and cleared by software. Callout boxes at the bottom explain the sequence: 'Software configures the DMA to receive 3 data blocks and enables the USART', 'DMA reads F1 from USART_DR', 'DMA reads F2 from USART_DR', 'DMA reads F3 from USART_DR', and 'The DMA transfer is complete (TCIF=1 in DMA_ISR)'.

Timing diagram for reception using DMA showing three frames (Frame 1, Frame 2, Frame 3) being received. The diagram tracks the TX line, RXNE flag, DMA request, USART_DR register, DMA reads, and DMA TCIF flag. Callouts explain the sequence: software configures DMA for 3 blocks, DMA reads F1, F2, and F3 from USART_DR, and finally the transfer is complete when TCIF=1.

Note: When FIFO management is enabled, the DMA request is triggered by receive FIFO not empty (i.e. RXFNE = 1).

Error flagging and interrupt generation in multi-buffer communication

In multi-buffer communication, if any error occurs during the transaction the error flag is asserted after the current byte. An interrupt is generated if the interrupt enable flag is set. For framing error, overrun error and noise flag which are asserted with RXNE (RXFNE in case FIFO mode is enabled) in single-byte reception, there is a separate error flag interrupt enable bit (EIE bit in the LPUART_CR3 register), which, if set, enables an interrupt after the current byte if any of these errors occur.

23.3.10 RS232 hardware flow control and RS485 driver enable

It is possible to control the serial data flow between 2 devices by using the nCTS input and the nRTS output. Figure 158. Hardware flow control between 2 LPUARTs shows how to connect 2 devices in this mode:

Figure 158. Hardware flow control between 2 LPUARTs

Diagram showing hardware flow control between two LPUARTs. LPUART 1's TX circuit is connected to LPUART 2's RX circuit via TX and RX lines. LPUART 1's RX circuit is connected to LPUART 2's TX circuit via RX and TX lines. Flow control lines are connected: nRTS from LPUART 1's RX circuit to nCTS input of LPUART 2's TX circuit, and nCTS from LPUART 1's TX circuit to nRTS input of LPUART 2's RX circuit.
Diagram showing hardware flow control between two LPUARTs. LPUART 1's TX circuit is connected to LPUART 2's RX circuit via TX and RX lines. LPUART 1's RX circuit is connected to LPUART 2's TX circuit via RX and TX lines. Flow control lines are connected: nRTS from LPUART 1's RX circuit to nCTS input of LPUART 2's TX circuit, and nCTS from LPUART 1's TX circuit to nRTS input of LPUART 2's RX circuit.

RS232 RTS and CTS flow control can be enabled independently by writing the RTSE and CTSE bits respectively to 1 (in the LPUART_CR3 register).

RS232 RTS flow control

If the RTS flow control is enabled (RTSE=1), then nRTS is asserted (tied low) as long as the LPUART receiver is ready to receive a new data. When the receive register is full, nRTS is deasserted, indicating that the transmission is expected to stop at the end of the current frame. Figure 159. RS232 RTS flow control shows an example of communication with RTS flow control enabled.

Figure 159. RS232 RTS flow control

Timing diagram for RS232 RTS flow control. The RX line shows two frames: 'Start bit | Data 1 | Stop bit' followed by 'Idle' then 'Start bit | Data 2 | Stop bit'. The nRTS line is initially low. It goes high when the first frame's stop bit is received (RXNE interrupt). It goes low again when 'Data 1 read' occurs, indicating the receiver is ready for 'Data 2'. It goes high again when the second frame's stop bit is received (RXNE interrupt).
Timing diagram for RS232 RTS flow control. The RX line shows two frames: 'Start bit | Data 1 | Stop bit' followed by 'Idle' then 'Start bit | Data 2 | Stop bit'. The nRTS line is initially low. It goes high when the first frame's stop bit is received (RXNE interrupt). It goes low again when 'Data 1 read' occurs, indicating the receiver is ready for 'Data 2'. It goes high again when the second frame's stop bit is received (RXNE interrupt).

Note: When FIFO mode is enabled, nRTS is deasserted only when RXFIFO is full.

RS232 CTS flow control

If the CTS flow control is enabled (CTSE=1), then the transmitter checks the nCTS input before transmitting the next frame. If nCTS is asserted (tied low), then the next data is transmitted (assuming that data is to be transmitted, in other words, if TXE/TXFE=0), otherwise the transmission does not occur. When nCTS is deasserted during a transmission, the current transmission is completed before the transmitter stops.

When CTSE=1, the CTSIF status bit is automatically set by hardware as soon as the CTS input toggles. It indicates when the receiver becomes ready or not ready for communication.

An interrupt is generated if the CTSIE bit in the LPUART_CR3 register is set. Figure 160. RS232 CTS flow control shows an example of communication with CTS flow control enabled.

Figure 160. RS232 CTS flow control

Timing diagram for RS232 CTS flow control showing nCTS, Transmit data register (TDR), and TX signal levels over time.

The diagram illustrates the relationship between the nCTS signal, the Transmit data register (TDR), and the TX signal during RS232 CTS flow control. The nCTS signal is shown as a horizontal line. The TDR is shown as a sequence of data blocks: Data 2, empty, Data 3, and empty. The TX signal is shown as a sequence of bits: Data 1, Stop bit, Start bit, Data 2, Stop bit, Idle, Start bit, and Data 3. Arrows indicate the flow of data from the TDR to the TX signal. The first arrow points from the 'empty' block in the TDR to the 'Data 2' block in the TX signal, labeled 'Writing data 3 in TDR'. The second arrow points from the 'Data 3' block in the TDR to the 'Data 3' block in the TX signal, labeled 'Transmission of Data 3 is delayed until nCTS = 0'. The nCTS signal is shown as a horizontal line that goes high (inactive) when the TDR is empty and low (active) when the TDR contains data. The TX signal is shown as a sequence of bits that are transmitted when the nCTS signal is low.

Timing diagram for RS232 CTS flow control showing nCTS, Transmit data register (TDR), and TX signal levels over time.

Note: For a correct behavior, nCTS must be asserted at least 3 LPUART clock source periods before the end of the current character. In addition, it should be noted that the CTSCF flag may not be set for pulses shorter than 2 x PCLK periods.

RS485 driver enable

The driver enable feature is enabled by setting bit DEM in the LPUART_CR3 control register. This allows the user to activate the external transceiver control through the DE (DriverEnable) signal. The assertion time is the time between the activation of the DE signal and the beginning of the START bit. It is programmed using the DEAT [4:0] bit fields in the LPUART_CR1 control register. The deassertion time is the time between the end of the last stop bit, in a transmitted message, and the deactivation of the DE signal. It is programmed using the DEDT [4:0] bit fields in the LPUART_CR1 control register. The polarity of the DE signal can be configured using the DEP bit in the LPUART_CR3 control register.

In LPUART, the DEAT and DEDT are expressed in LPUART clock source ( \( f_{CK} \) ) cycles:

    • • The driver enable assertion time=
      • \( (1 + (DEAT \times P)) \times f_{CK} \) , if \( P \neq 0 \)
      • \( (1 + DEAT) \times f_{CK} \) , if \( P = 0 \)
    • • The driver enable deassertion time=
      • \( (1 + (DEDT \times P)) \times f_{CK} \) , if \( P \neq 0 \)
      • \( (1 + DEDT) \times f_{CK} \) , if \( P = 0 \)
  1. with \( P = BRR[20:11] \)

23.3.11 Wakeup from Deepstop mode

The LPUART is able to wake up the MCU from Deepstop mode when the UESM bit is set and the LPUART clock is set to LSE (refer to Section 6: Reset and clock controller (RCC) ).

When FIFO mode is disabled, the MCU wakeup from Deepstop mode can be done using the standard RXNE interrupt. In this case, the RXNEIE bit must be set before entering Deepstop mode.

When FIFO mode is enabled, the MCU wakeup from Deepstop mode can be done using the:

In order to avoid overrun/underrun errors and transmit/receive data in Deepstop mode, the MCU wakeup from Deepstop mode can be done also using the:

An application can set the threshold to the maximum RXFIFO size if the wakeup time is less than the time to receive a single byte across the line.

Using the RXFIFO full, TXFIFO empty, and RXFIFO/TXFIFO threshold interrupts to wake up the MCU from Deepstop mode allows doing as many USART transfers as possible during Deepstop mode with the benefit of optimizing consumption.

Alternatively, a specific interrupt may be selected through the WUS bit fields.

In order to be able to wake up the MCU from Deepstop mode, the UESM bit in the USART_CR1 control register must be set before entering Deepstop mode.

When the wakeup event is detected, the WUF flag is set by hardware and a wakeup interrupt is generated if the WUFIE bit is set.

Note: Before entering Deepstop mode, the user must ensure that the USART is not performing a transfer. BUSY flag cannot ensure that Deepstop mode is never entered during a running reception.

Note: The WUF flag is set when a wakeup event is detected, independently of whether the MCU is in Deepstop or in an active mode.

Note: When entering Deepstop mode just after having initialized and enabled the receiver, the REACK bit must be checked to ensure the USART is actually enabled.

Note: When DMA is used for reception, it must be disabled before entering Deepstop mode and re-enabled upon exit from Deepstop mode.

Note: The wakeup from Deepstop mode feature is not available for all modes. For example it doesn't work in SPI mode because the SPI operates in master mode only.

Note: When FIFO is enabled, the wakeup from Deepstop mode on address match is only possible when mute mode is enabled.

Using Mute mode with Deepstop mode

If the USART is put into Mute mode before entering Deepstop mode:

Note: When FIFO management is enabled, mute mode is used with wakeup from Deepstop mode without any constraints (i.e. the two points mentioned above about mute and Deepstop mode are valid only when FIFO management is disabled).

23.4 LPUART interrupts

These events generate an interrupt if the corresponding enable control bit is set.

Table 107. LPUART interrupts

Interrupt eventEvent flagEnable Control bitInterrupt clear methodInterrupt activated
lpuart_itlpuart_wkup
Transmit data register emptyTXETXEIETXE cleared when a data is written in TDRYESNO
Transmit FIFO not fullTXFNFTXFNFIETXFNF cleared when TXFIFO is fullYESNO
Transmit FIFO emptyTXFETXFEIETXFE cleared when the TXFIFO contains at least one data or by setting TXFRQ bitYESYES
Transmit FIFO threshold reachedTXFTTXFTIETXFT cleared by hardware when the TXFIFO content is less than programmed thresholdYESYES
CTS interruptCTSIFCTSIECTSIF cleared by software by setting CTSCF bitYESNO
Transmission completeTCTCIETC cleared when a data is written in TDR or by setting TCCF bitYESNO
Receive data register not empty (data ready to be read)RXNERXNEIERXNE cleared by reading RDR or by setting RXFRQ bitYESYES
Receive FIFO not emptyRXFNERXFNEIERXFNE cleared when the RXFIFO is empty or by setting RXFRQ bitYESYES
Receive FIFO fullRXFF (1)RXFFIERXFF cleared when the RXFIFO contains at least one dataYESYES
Receive FIFO threshold reachedRXFTRXFTIERXFT cleared by hardware when the RXFIFO content is less than programmed thresholdYESYES
Overrun error detectedORERX-NEIE/RX-FNEIEORE cleared by setting ORECF bitYESNO
Idle line detectedIDLEIDLEIEIDLE cleared by setting IDLECF bitYESNO
Parity errorPEPEIEPE cleared by setting PECF bitYESNO
Noise error, overrun error and framing error in multi-buffer communicationNE or OREor FEEIENE cleared by setting NECF bit. OREcleared by setting ORECF bit. FE flag cleared by setting FECF bit.YESNO
Character matchCMFCMIECMF cleared by setting CMCF bitYESNO
Wakeup from low-power mode(2)WUFIEWUF is cleared by setting WUCF bitYESYES

1. RXFF flag is asserted if the LPUART receives n+1 data (n being the RXFIFO size): n data in the RXFIFO and 1 data in LPUART_RDR. In DEESTOP mode, LPUART_RDR is not clocked. As a result, this register is not written and once n data are received and written in the RXFIFO, the RXFF interrupt is asserted (RXFF flag is not set).

2. The WUF interrupt is active only in low-power mode

23.5 LPUART registers

Refer to Section 1.5: Acronyms for a list of abbreviations used in register descriptions.

23.5.1 Control register 1 (LPUART_CR1)

Address offset: 0x00

Reset value: 0x0000

31302928272625242322212019181716
RXFFIETXFEIEFIFOENM1Res.Res.DEAT[4:0]DEDT[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.CMIEMMEM0WAKEPCEPSPEIETXEIE
TXFNIE
TCIERXNEIE
RXFNEIE
IDLEIETEREUESMUE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Bit 31

RXFFIE: RXFIFO full interrupt enable. This bit is set and cleared by software.

0: Interrupt is inhibited

1: An LPUART interrupt is generated when RXFF=1 in the LPUART_ISR register

Note: When FIFO mode is disabled, this bit is reserved and must be kept at reset value.

Bit 30

TXFEIE: TXFIFO empty interrupt enable. This bit is set and cleared by software.

0: Interrupt is inhibited

1: An LPUART interrupt is generated when TXFE=1 in the LPUART_ISR register.

Note: When FIFO mode is disabled, this bit is reserved and must be kept at reset value.

Bit 29

FIFOEN: FIFO mode enable.

This bit is set and cleared by software.

0: FIFO mode is disabled

1: FIFO mode is enabled

Bit 28

M1: Word length.

This bit, with bit 12 (M0) determines the word length. It is set or cleared by software.

M[1:0] = 00: 1 start bit, 8 data bits, n stop bit

M[1:0] = 01: 1 start bit, 9 data bits, n stop bit

M[1:0] = 10: 1 start bit, 7 data bits, n Stop bit

This bit can only be written when the LPUART is disabled (UE=0).

Note: in 7-bits data length mode, the Smartcard mode, LIN master mode and auto baud rate (0x7F and 0x55 frames detection) are not supported.

Bit 27Reserved, must be kept at reset value.
Bit 26Reserved, must be kept at reset value.
Bits 25:21

DEAT[4:0]: Driver enable assertion time.

This 5-bit value defines the time between the activation of the DE (driver enable) signal and the beginning of the start bit. It is expressed in UCLK (LPUART clock) clock cycles.

For more details, refer to RS485 driver enable section.

This bit field can only be written when the LPUART is disabled (UE=0).

Bits 20:16

DEDT[4:0]: Driver enable de-assertion time.

This 5-bit value defines the time between the end of the last stop bit, in a transmitted message, and the de-activation of the DE (Driver Enable) signal. It is expressed in UCLK (LPUART clock) clock cycles. For more details, refer to RS485 driver enable section. If the LPUART_TDR register is written during the DEDT time, the new data is transmitted only when the DEDT and DEAT times have both elapsed.

This bit field can only be written when the LPUART is disabled (UE=0).
Bit 15Reserved, must be kept at reset value.
Bit 14CMIE: Character match interrupt enable. This bit is set and cleared by software.
0: Interrupt is inhibited
1: An LPUART interrupt is generated when the CMF bit is set in the LPUART_ISR register
Bit 13MME: Mute mode enable.
This bit activates the mute mode function of the LPUART. When set, the LPUART can switch between the active and mute modes, as defined by the WAKE bit. It is set and cleared by software.
0: Receiver in active mode permanently
1: Receiver can switch between mute mode and active mode
Bit 12M0: Word length.
This bit, with bit 28 (M1) determines the word length. It is set or cleared by software. See Bit 28 (M1) description.
This bit can only be written when the LPUART is disabled (UE=0).
Bit 11WAKE: Receiver wakeup method.
This bit determines the LPUART wakeup method from mute mode. It is set or cleared by software.
0: Idle line
1: Address mark
This bit field can only be written when the LPUART is disabled (UE=0).
Bit 10PCE: Parity control enable.
This bit selects the hardware parity control (generation and detection). When the parity control is enabled, the computed parity is inserted at the MSB position (9th bit if M=1; 8th bit if M=0) and parity is checked on the received data. This bit is set and cleared by software. Once it is set, PCE is active after the current byte (in reception and in transmission).
0: Parity control disabled
1: Parity control enabled
This bit field can only be written when the LPUART is disabled (UE=0).
Bit 9PS: Parity selection.
This bit selects the odd or even parity when the parity generation/detection is enabled (PCE bit set). It is set and cleared by software. The parity is selected after the current byte.
0: Even parity
1: Odd parity
This bit field can only be written when the LPUART is disabled (UE=0).
Bit 8PEIE: PE interrupt enable.
This bit is set and cleared by software.
0: Interrupt is inhibited
1: An LPUART interrupt is generated whenever PE=1 in the LPUART_ISR register
Bit 7TXEIE/TXFNFIE: Transmit data register empty/TXFIFO not full interrupt enable. This bit is set and cleared by software.
0: Interrupt is inhibited
1: An LPUART interrupt is generated whenever TXE/TXFNF=1 in the LPUART_ISR register
Bit 6TCIE: Transmission complete interrupt enable. This bit is set and cleared by software.
0: Interrupt is inhibited
1: An LPUART interrupt is generated whenever TC=1 in the LPUART_ISR register
Bit 5RXNEIE/RXFNEIE: Receive data register not empty/RXFIFO not empty interrupt enable. This bit is set and cleared by software.
0: Interrupt is inhibited
1: An LPUART interrupt is generated whenever ORE=1 or RXNE/RXFNE=1 in the LPUART_ISR register
Bit 4

IDLEIE: IDLE interrupt enable.

This bit is set and cleared by software.

0: Interrupt is inhibited

1: An LPUART interrupt is generated whenever IDLE=1 in the LPUART_ISR register

Bit 3

TE: Transmitter enable.

This bit enables the transmitter. It is set and cleared by software.

0: Transmitter is disabled

1: Transmitter is enabled

Note: During transmission, a “0” pulse on the TE bit (“0” followed by “1”) sends a preamble (idle line) after the current word. In order to generate an idle character, the TE must not be immediately written to 1. In order to ensure the required duration, the software can poll the TEACK bit in the LPUART_ISR register.

When TE is set there is a 1 bit-time delay before the transmission starts.

Bit 2

RE: Receiver enable.

This bit enables the receiver. It is set and cleared by software.

0: Receiver is disabled

1: Receiver is enabled and begins searching for a start bit

Bit 1

UESM: LPUART enable in Deepstop mode

When this bit is cleared, the LPUART is not able to wake up the MCU from Deepstop mode. When this bit is set, the LPUART is able to wake up the MCU from Deepstop mode, provided that the LPUART clock selection is LSE in the RCC. This bit is set and cleared by software.

0: LPUART not able to wake up the MCU from Deepstop mode.

1: LPUART able to wake up the MCU from Deepstop mode. When this function is active, the clock source for the LPUART must be LSE (see Section 6: Reset and clock controller (RCC) ).

Note: It is recommended to set the UESM bit just before entering Deepstop mode and clear it on exit from Deepstop mode.

Bit 0

UE: LPUART enable.

When this bit is cleared, the LPUART prescalers and outputs are stopped immediately, and current operations are discarded. The configuration of the LPUART is kept, but all the status flags, in the LPUART_ISR are reset. This bit is set and cleared by software.

0: LPUART prescaler and outputs disabled, low-power mode

1: LPUART enabled

Note: In order to go into low-power mode without generating errors on the line, the TE bit must be reset before and the software must wait for the TC bit in the LPUART_ISR to be set before resetting the UE bit.

The DMA requests are also reset when UE = 0 so the DMA channel must be disabled before resetting the UE bit.

23.5.2 Control register 2 (LPUART_CR2)

Address offset: 0x04

Reset value: 0x0000

31302928272625242322212019181716
ADD[7:4]ADD[3:0]Res.Res.Res.Res.MSBFIRSTDATAINVTXINVRXINV
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SWAPRes.STOP[1:0]Res.Res.Res.Res.Res.Res.Res.ADDM7Res.Res.Res.Res.
rwrwrwrw
Bits 31:28

ADD[7:4]: Address of the LPUART node.

This bit-field gives the address of the LPUART node or a character code to be recognized.

This is used in multiprocessor communication during mute mode or Deepstop mode, for wakeup with 7- bit address mark detection. The MSB of the character sent by the transmitter should be equal to 1. It may also be used for character detection during normal reception, mute mode inactive (for example, end of block detection in ModBus protocol). In this case, the whole received character (8-bit) is compared to the ADD[7:0] value and CMF flag is set on match.

This bit field can only be written when reception is disabled (RE=0) or the LPUART is disabled (UE=0).

Bits 27:24

ADD[3:0]: Address of the LPUART node.

This bit-field gives the address of the LPUART node or a character code to be recognized.

This is used in multiprocessor communication during Mute mode or Deepstop mode, for wakeup with address mark detection.

This bit field can only be written when reception is disabled (RE=0) or the LPUART is disabled (UE=0)

Bit 23:20Reserved, must be kept at reset value.
Bit 19

MSBFIRST: Most significant bit first.

This bit is set and cleared by software.

0: Data is transmitted/received with data bit 0 first, following the start bit

1: Data is transmitted/received with the MSB (bit 7/8) first, following the start bit. This bit field can only be written when the LPUART is disabled (UE=0).

Bit 18

DATAINV: Binary data inversion.

This bit is set and cleared by software.

0: Logical data from the data register are sent/received in positive/direct logic. (1=H, 0=L)

1: Logical data from the data register are sent/received in negative/inverse logic. (1=L, 0=H). The parity bit is also inverted.

This bit field can only be written when the LPUART is disabled (UE=0).

Bit 17

TXINV: TX pin active level inversion. This bit is set and cleared by software.

0: TX pin signal works using the standard logic levels (VDD =1/idle, Gnd=0/mark)

1: TX pin signal values are inverted. (VDD =0/mark, Gnd=1/idle). This allows the use of an external inverter on the TX line.

This bit field can only be written when the LPUART is disabled (UE=0).

Bit 16

RXINV: RX pin active level inversion. This bit is set and cleared by software.

0: RX pin signal works using the standard logic levels (VDD =1/idle, Gnd=0/mark)

1: RX pin signal values are inverted. (VDD =0/mark, Gnd=1/idle). This allows the use of an external inverter on the RX line.

This bit field can only be written when the LPUART is disabled (UE=0).

Bit 15

SWAP: Swap TX/RX pins.

This bit is set and cleared by software.

0: TX/RX pins are used as defined in standard pinout

1: TX and RX pins functions are swapped. This bit field can only be written when the LPUART is disabled (UE=0).

1: The TX and RX pins functions are swapped. This allows to work in the case of a cross-wired connection to another UART.

This bit field can only be written when the LPUART is disabled (UE=0).

Bit 14Reserved, must be kept at reset value.
Bits 13:12

STOP[1:0] : STOP bits.

These bits are used for programming the stop bits.

00: 1 stop bit

01: Reserved

10: 2 stop bits

11: Reserved

This bit field can only be written when the LPUART is disabled (UE=0).

Bit 11:5Reserved, must be kept at reset value.
Bit 4

ADD7 : 7-bit Address Detection/4-bit Address Detection.

This bit is for selection between 4-bit address detection or 7-bit address detection.

0: 4-bit address detection

1: 7-bit address detection (in 8-bit data mode)

This bit can only be written when the LPUART is disabled (UE=0).

Note: In 7-bit and 9-bit data modes, the address detection is done on 6-bit and 8-bit address (ADD[5:0] and ADD[7:0]) respectively.

Bits 3:0Reserved, must be kept at reset value.

23.5.3 Control register 3 (LPUART_CR3)

Address offset: 0x08

Reset value: 0x0000

31302928272625242322212019181716
TXFTCFGRXFTI E.RXFTCFGRes.TXFTIEWUFIEWUS[2:0]Res.Res.Res.
rwrwrwrwrwrwrw
1514131211109876543210
DEPDEMDDREOVRDISRes.CTSIECTSERTSEDMATDMARRes.Res.HD SELRes.Res.EIE
rwrwrwrwrwrwrwrwrwrwrw
Bits 31:29

TXFTCFG: TXFIFO threshold configuration.

000: TXFIFO reaches 1/8 of its depth
001: TXFIFO reaches 1/4 of its depth
110: TXFIFO reaches 1/2 of its depth
011: TXFIFO reaches 3/4 of its depth
100: TXFIFO reaches 7/8 of its depth
101: TXFIFO becomes empty
Remaining combinations: Reserved.

Bit 28

RXFTIE: RXFIFO threshold interrupt enable. This bit is set and cleared by software.

0: Interrupt is inhibited
1: An LPUART interrupt is generated when Receive FIFO reaches the threshold programmed in RXFTCFG

Bits 27:25

RXFTCFG: Receive FIFO threshold configuration.

000: Receive FIFO reaches 1/8 of its depth
001: Receive FIFO reaches 1/4 of its depth
110: Receive FIFO reaches 1/2 of its depth
011: Receive FIFO reaches 3/4 of its depth
100: Receive FIFO reaches 7/8 of its depth
101: Receive FIFO becomes full
Remaining combinations: Reserved.

Bit 24

Reserved, must be kept at reset value.

Bit 23

TXFTIE: TXFIFO threshold interrupt enable. This bit is set and cleared by software.

0: Interrupt is inhibited
1: An LPUART interrupt is generated when TXFIFO reaches the threshold programmed in TXFTCFG

Bit 22

WUFIE: Wakeup from Deepstop mode interrupt enable .

This bit is set and cleared by software.

0: Interrupt is inhibited
1: An LPUART interrupt is generated whenever WUF=1 in the LPUART_ISR register

Note: WUFIE must be set before entering in Deepstop mode. The WUF interrupt is active only in Deepstop mode. If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.

Bits 21:20

WUS[1:0]: Wakeup from Deepstop mode interrupt flag selection.

This bit-field specify the event which activates the WUF (Wakeup from Deepstop mode flag).

00:WUF active on address match (as defined by ADD[7:0] and ADDM7)
01:Reserved.
10: WUF active on Start bit detection

11: WUF active on RXNE.

This bit field can only be written when the LPUART is disabled (UE=0).

Note: If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.

Bits 19:16Reserved, must be kept at reset value.
Bit 15

DEP: Driver enable polarity selection.

0: DE signal is active high

1: DE signal is active low

This bit can only be written when the LPUART is disabled (UE=0).

Bit 14

DEM: Driver enable mode.

This bit allows the user to activate the external transceiver control through the DE signal.

0: DE function is disabled

1: DE function is enabled. The DE signal is output on the RTS pin.

This bit can only be written when the LPUART is disabled (UE=0).

Bit 13

DDRE: DMA disable on reception error.

0: DMA is not disabled in case of reception error. The corresponding error flag is set but RXNE is kept 0 preventing from overrun. As a consequence, the DMA request is not asserted, so the erroneous data is not transferred (no DMA request), but next correct received data is transferred.

1: DMA is disabled following a reception error. The corresponding error flag is set, as well as RXNE. The DMA request is masked until the error flag is cleared. This means that the software must first disable the DMA request (DMAR = 0) or clear RXNE before clearing the error flag.

This bit can only be written when the LPUART is disabled (UE=0).

Note: The reception errors are: parity error, framing error or noise error.

Bit 12

OVRDIS: Overrun disable.

This bit is used to disable the receive overrun detection.

0: Overrun Error Flag, ORE, is set when received data is not read before receiving new data

1: Overrun functionality is disabled. If new data is received while the RXNE flag is still set the ORE flag is not set and the new received data overwrites the previous content of the LPUART_RDR register.

This bit can only be written when the LPUART is disabled (UE=0).

Note: This control bit allows checking the communication flow w/o reading the data.

Bit 11Reserved, must be kept at reset value.
Bit 10

CTSIE: CTS interrupt enable.

0: Interrupt is inhibited

1: An interrupt is generated whenever CTSIF=1 in the LPUART_ISR register

Bit 9

CTSE: CTS enable.

0: CTS hardware flow control disabled

1: CTS mode enabled, data is only transmitted when the nCTS input is asserted (tied to 0). If the nCTS input is de-asserted while data is being transmitted, then the transmission is completed before stopping. If data is written into the data register while nCTS is asserted, the transmission is postponed until nCTS is asserted.

This bit can only be written when the LPUART is disabled (UE=0).

Bit 8

RTSE: RTS enable.

0: RTS hardware flow control disabled

1: RTS output enabled, data is only requested when there is space in the receive buffer. The transmission of data is expected to cease after the current character has been transmitted. The nRTS output is asserted (pulled to 0) when data can be received.

This bit can only be written when the LPUART is disabled (UE=0).

Bit 7

DMAT: DMA enable transmitter. This bit is set/reset by software.

1: DMA mode is enabled for transmission

0: DMA mode is disabled for transmission
Bit 6DMAR : DMA enable receiver. This bit is set/reset by software.
1: DMA mode is enabled for reception
0: DMA mode is disabled for reception
Bit 5:4Reserved, must be kept at reset value.
Bit 3HDSEL : Half-duplex selection.
Selection of single-wire half-duplex mode.
0: Half-duplex mode is not selected
1: Half-duplex mode is selected
This bit can only be written when the LPUART is disabled (UE=0).
Bit 2:1Reserved, must be kept at reset value.
Bit 0EIE : Error interrupt enable.
Error interrupt enable bit is required to enable interrupt generation in case of a framing error, overrun error or noise flag (FE=1 or ORE=1 or NF=1 in the LPUART_ISR register).
0: Interrupt is inhibited
1: An interrupt is generated when FE=1 or ORE=1 or NF=1 in the LPUART_ISR register

23.5.4 Baud rate register (LPUART_BRR)

This register can only be written when the LPUART is disabled (UE=0). It may be automatically updated by hardware in auto baud rate detection mode.

Address offset: 0x0C

Reset value: 0x0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.BRR[19:16]
rwrwrwrw
1514131211109876543210
BRR[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
Bits 31:20Reserved, must be kept at reset value.
Bits 19:0BRR[19:0]

Note: It is forbidden to write values less than 0x300 in the LPUART_BRR register. Provided that LPUART_BRR must be >= 0x300 and LPUART_BRR is 20 bits, care should be taken when generating high baud rates using high f ck values. f ck must be in the range [3 x baud rate ..4096 x baud rate].

23.5.5 Request register (LPUART_RQR)

Address offset: 0x18

Reset value: 0x0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
151413121110987654321
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TXFRQRXFRQMMRQSBKRQRes.
wwww
Bits 31:5Reserved, must be kept at reset value.
Bit 4TXFRQ: Transmit data flush request.
This bit is used when FIFO mode is enabled. TXFRQ bit is set to flush the whole FIFO. This sets the flag TXFE (TXFIFO empty, bit 23 in the LPUART_ISR register).
Note: In FIFO mode, the TXFNF flag is reset during the flush request until TxFIFO is empty in order to ensure that no data is written in the data register.
Bit 3RXFRQ: Receive data flush request.
Writing 1 to this bit clears the RXNE flag.
This allows the received data to be discarded without reading it, and avoid an overrun condition.
Bit 2MMRQ: Mute mode request.
Writing 1 to this bit puts the LPUART in mute mode and resets the RWU flag.
Bit 1SBKRQ: Send break request.
Writing 1 to this bit sets the SBKF flag and request to send a BREAK on the line, as soon as the transmit machine is available.
Note: In the case the application needs to send the break character following all previously inserted data, including the ones not yet transmitted, the software should wait for the TXE flag assertion before setting the SBKRQ bit.
Bit 0Reserved, must be kept at reset value.

23.5.6 Interrupt and status register (LPUART_ISR)

Address offset: 0x1C

Reset value: 0x00C0 (in case FIFO disabled)

Reset value: 0x08000C0 (in case FIFO enabled)

31302928272625242322212019181716
Res.Res.Res.Res.TXFTRXFTRes.RXFFTXFERE ACKTE ACKWUFRWUSBKFCMFBUSY
rrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.CTSCTSIFRes.TXETCRXNEIDLEORENFFEPE
rrrrrrrrrr
Bits 31:28Reserved, must be kept at reset value.
Bit 27TXFT: TXFIFO threshold flag.
This bit is set by hardware when the TXFIFO reaches the programmed threshold in TXFTCFG in LPUARTx_CR3 register, i.e. the TXFIFO contains TXFTCFG empty locations. An interrupt is generated if the TXFTIE bit = 1 (bit 31) in the LPUART_CR3 register.
0: TXFIFO does not reach the programmed threshold
1: TXFIFO reached the programmed threshold
Bit 26RXFT: RXFIFO threshold flag.
This bit is set by hardware when the RXFIFO reaches the programmed threshold in RXFTCFG in LPUARTx_CR3 register, i.e. the Receive FIFO contains RXFTCFG data. An interrupt is generated if the RXFTIE bit = 1 (bit 27) in the LPUART_CR3 register.
0: Receive FIFO does not reach the programmed threshold
1: Receive FIFO reached the programmed threshold
Bit 25Reserved, must be kept at reset value.
Bit 24RXFF: RXFIFO Full.
This bit is set by hardware when RXFIFO is Full.
An interrupt is generated if the RXFFIE bit = 1 in the LPUART_CR1 register.
0: RXFIFO is not full
1: RXFIFO is full
Bit 23TXFE: TXFIFO empty.
This bit is set by hardware when TXFIFO is empty. When the TXFIFO contains at least one data, this flag is cleared. The TXFE flag can also be set by writing 1 to the bit TXFRQ (bit 4) in the LPUART_RQR register.
An interrupt is generated if the TXFEIE bit = 1 (bit 30) in the LPUART_CR1 register.
0: TXFIFO is not empty
1: TXFIFO is empty
Bit 22REACK: Receive enable acknowledge flag.
This bit is set/reset by hardware when the Receive Enable value is taken into account by the LPUART.
It can be used to verify that the LPUART is ready for reception before entering Deepstop mode.
Note: If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.
Bit 21TEACK: Transmit enable acknowledge flag.
This bit is set/reset by hardware, when the Transmit Enable value is taken into account by the LPUART.
It can be used when an idle frame request is generated by writing TE=0, followed by TE=1 in the LPUART_CR1 register, in order to respect the TE=0 minimum period.
Bit 20

WUF: Wakeup from Deepstop mode flag This bit is set by hardware, when a wakeup event is detected. The event is defined by the WUS bit field. It is cleared by software, writing a 1 to the WUCF in the LPUART_ICR register. An interrupt is generated if WUFIE=1 in the LPUART_CR3 register.

Note: When UESM is cleared, WUF flag is also cleared. The WUF interrupt is active only in Deepstop mode. If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.

Bit 19

RWU: Receiver wakeup from mute mode.

This bit indicates if the LPUART is in mute mode. It is cleared/set by hardware when a wakeup/mute sequence is recognized. The mute mode control sequence (address or IDLE) is selected by the WAKE bit in the LPUART_CR1 register.

When wakeup on IDLE mode is selected, this bit can only be set by software, writing 1 to the MMRQ bit in the LPUART_RQR register.

0: Receiver in active mode

1: Receiver in mute mode

Note: If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.

Bit 18

SBKF: Send break flag.

This bit indicates that a send break character was requested. It is set by software, by writing 1 to the SBKRQ bit in the LPUART_CR3 register. It is automatically reset by hardware during the stop bit of break transmission.

0: No break character is transmitted

1: Break character is transmitted

Bit 17

CMF: Character match flag.

This bit is set by hardware, when a the character defined by ADD[7:0] is received. It is cleared by software, writing 1 to the CMCF in the LPUART_ICR register.

An interrupt is generated if CMIE=1 in the LPUART_CR1 register.

0: No character match detected

1: Character match detected

Bit 16

BUSY: Busy flag.

This bit is set and reset by hardware. It is active when a communication is on-going on the RX line (successful start bit detected). It is reset at the end of the reception (successful or not).

0: LPUART is idle (no reception)

1: Reception on-going

Bits 15:11Reserved, must be kept at reset value.
Bit 10

CTS: CTS flag.

This bit is set/reset by hardware. It is an inverted copy of the status of the nCTS input pin.

0: nCTS line set

1: nCTS line reset

Note: If the hardware flow control feature is not supported, this bit is reserved and forced by hardware to '0'.

Bit 9

CTSIF: CTS interrupt flag.

This bit is set by hardware when the nCTS input toggles, if the CTSE bit is set. It is cleared by software, by writing 1 to the CTSCF bit in the LPUART_ICR register.

An interrupt is generated if CTSIE=1 in the LPUART_CR3 register.

0: No change occurred on the nCTS status line

1: A change occurred on the nCTS status line

Note: If the hardware flow control feature is not supported, this bit is reserved and forced by hardware to '0'.

Bit 8Reserved, must be kept at reset value.
Bit 7

TXE/TXNF: Transmit data register empty/TXFIFO not full.

When FIFO mode is disabled, TXE is set by hardware when the content of the LPUARTx_TDR register has been transferred into the shift register. It is cleared by a write to the LPUARTx_TDR register.

When FIFO mode is enabled, TXFNF is set by hardware when TXFIFO is not full, and so data can be written in the LPUART_TDR. Every write in the LPUART_TDR places the data in the TXFIFO. This flag remains set until the TXFIFO is full. When the TXFIFO is full, this flag is cleared indicating that data can not be written into the LPUART_TDR.

Note: The TXFNF is kept reset during the flush request until TXFIFO is empty. After sending the flush request (by setting TXFRQ bit), the flag TXFNF should be checked prior to writing in TXFIFO. (TXFNF and TXFE is set at the same time).

An interrupt is generated if the TXEIE/TXFNFIE bit = 1 in the LPUART_CR1 register.

0: Data register is full/Transmit FIFO is full

1: Data register/Transmit FIFO is not full

Note: This bit is used during single buffer transmission.

Bit 6

TC: Transmission complete.

This bit is set by hardware if the transmission of a frame containing data is complete and if TXE/TXFF is set. An interrupt is generated if TCIE=1 in the LPUART_CR1 register. It is cleared by software, writing 1 to the TCCF in the LPUART_ICR register or by a write to the LPUART_TDR register.

An interrupt is generated if TCIE=1 in the LPUART_CR1 register.

0: Transmission is not complete

1: Transmission is complete

Note: If TE bit is reset and no transmission is on-going, the TC bit is set immediately.

Bit 5

RXNE/RXFNE: Read data register not empty/RXFIFO not empty.

RXNE bit is set by hardware when the content of the LPUARTx_RDR shift register has been transferred to the LPUARTx_RDR register. It is cleared by a read to the LPUARTx_RDR register. The RXNE flag can also be cleared by writing 1 to the RXFRQ in the LPUARTx_RQR register. RXFNE bit is set by hardware when the RXFIFO is not empty, and so data can be read from the LPUART_RDR register. Every read of the LPUART_RDR frees a location in the RXFIFO. It is cleared when the RXFIFO is empty.

The RXNE/RXFNE flag can also be cleared by writing 1 to the RXFRQ in the LPUART_RQR register.

An interrupt is generated if RXNEIE/RXFNEIE=1 in the LPUART_CR1 register.

0: Data is not received

1: Received data is ready to be read

Bit 4

IDLE: Idle line detected.

This bit is set by hardware when an idle line is detected. An interrupt is generated if IDLEIE=1 in the LPUART_CR1 register. It is cleared by software, writing 1 to the IDLECF in the LPUART_ICR register.

0: No Idle line is detected

1: Idle line is detected

Note: The IDLE bit is not set again until the RXNE bit has been set (i.e. a new idle line occurs).

If mute mode is enabled (MME=1), IDLE is set if the LPUART is not mute (RWU=0), whatever the mute mode selected by the WAKE bit. If RWU=1, IDLE is not set.

Bit 3

ORE: Overrun error.

This bit is set by hardware when the data currently being received in the shift register is ready to be transferred into the LPUARTx_RDR register while RXNE=1 (RXFF=1 in case FIFO mode is enabled). It is cleared by a software, writing 1 to the ORECF, in the LPUARTx_ICR register.

An interrupt is generated if RXNEIE/ RXFNEIE=1 or EIE=1 in the LPUARTx_CR1 register.

0: No overrun error

1: Overrun error is detected

Note: When this bit is set, the LPUART_RDR register content is not lost but the shift register is overwritten. An interrupt is generated if the ORE flag is set during multi-buffer communication if the EIE bit is set.

This bit is permanently forced to 0 (no overrun detection) when the bit OVRDIS is set in the LPUART_CR3 register.

Bit 2

NF: START bit noise detection flag.

This bit is set by hardware when noise is detected on the START bit of a received frame. It is cleared by software, writing 1 to the NFCF bit in the LPUART_ICR register.

0: No noise is detected

1: Noise is detected

Note: This bit does not generate an interrupt as it appears at the same time as the RXNE/RXFNE bit which itself generates an interrupt. An interrupt is generated when the NF flag is set during multi buffer communication if the EIE bit is set.

Note: In FIFO mode, this error is associated with the character in the LPUART_RDR.

Bit 1

FE: Framing error.

This bit is set by hardware when a de-synchronization, excessive noise or a break character is detected. It is cleared by software, writing 1 to the FECF bit in the LPUART_ICR register. In Smartcard mode, in transmission, this bit is set when the maximum number of transmit attempts is reached without success (the card NACKs the data frame).

An interrupt is generated if EIE=1 in the LPUART_CR1 register.

0: No framing error is detected

1: Framing error or break character is detected

Note: In FIFO mode, this error is associated with the character in the LPUART_RDR.

Bit 0

PE: Parity error.

This bit is set by hardware when a parity error occurs in receiver mode. It is cleared by software, writing 1 to the PECF in the LPUART_ICR register.

An interrupt is generated if PEIE=1 in the LPUART_CR1 register.

0: No parity error

1: Parity error

Note: In FIFO mode, this error is associated with the character in the LPUART_RDR.

23.5.7 Interrupt flag clear register (LPUART_ICR)

Address offset: 0x20

Reset value: 0x0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WUCFRes.Res.CMCFRes.
w_r0w_r0
1514131211109876543210
Res.Res.Res.Res.Res.Res.CTSCFRes.Res.TCCFRes.IDLECFORECFNECFFECFPECF
w_r0w_r0w_r0w_r0w_r0w_r0w_r0
Bits 31:21Reserved, must be kept at reset value.
Bit 20WUCF: Wakeup from Deepstop mode clear flag. Writing 1 to this bit clears the WUF flag in the LPUART_ISR register.
Note: If the LPUART does not support the wakeup from Deepstop feature, this bit is reserved and forced by hardware to '0'.
Bit 19:18Reserved, must be kept at reset value.
Bit 17CMCF: Character match clear flag.
Writing 1 to this bit clears the CMF flag in the LPUART_ISR register.
Bit 16:10Reserved, must be kept at reset value.
Bit 9CTSCF: CTS clear flag.
Writing 1 to this bit clears the CTSIF flag in the LPUART_ISR register.
Bit 8:7Reserved, must be kept at reset value.
Bit 6TCCF: Transmission complete clear flag. Writing 1 to this bit clears the TC flag in the LPUART_ISR register.
Bit 5Reserved, must be kept at reset value.
Bit 4IDLECF: Idle line detected clear flag. Writing 1 to this bit clears the IDLE flag in the LPUART_ISR register.
Bit 3ORECF: Overrun error clear flag. Writing 1 to this bit clears the ORE flag in the LPUART_ISR register.
Bit 2NECF: Noise detected clear flag. Writing 1 to this bit clears the NF flag in the LPUART_ISR register.
Bit 1FECF: Framing error clear flag. Writing 1 to this bit clears the FE flag in the LPUART_ISR register.
Bit 0PECF: Parity error clear flag. Writing 1 to this bit clears the PE flag in the LPUART_ISR register.

23.5.8 Receive data register (LPUART_RDR)

Address offset: 0x24

Reset value: undefined

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.RDR[8:0]
rrrrrrrrr
Bits 31:9Reserved, must be kept at reset value.
Bits 8:0RDR[8:0]: Receive data value contains the received data character.
The RDR register provides the parallel interface between the input shift register and the internal bus (see Figure 149. LPUART block diagram ).
When receiving with the parity enabled, the value read in the MSB bit is the received parity bit.

23.5.9 Transmit data register (LPUART_TDR)

Address offset: 0x28

Reset value: undefined

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.TDR[8:0]
rwrwrwrwrwrwrwrwrw
Bits 31:9Reserved, must be kept at reset value.
Bits 8:0

TDR[8:0]: Transmit data value contains the data character to be transmitted.

The TDR register provides the parallel interface between the internal bus and the output shift register (see Figure 149. LPUART block diagram ).

When transmitting with the parity enabled (PCE bit set to 1 in the LPUART_CR1 register), the value written in the MSB (bit 7 or bit 8 depending on the data length) has no effect because it is replaced by the parity.

Note: This register must be written only when TXE/TXFNF=1.

23.5.10 Prescaler register (LPUART_PRESC)

This register can only be written when the USART is disabled (UE=0).

Address offset: 0x2C

Reset value: 0x0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PRESCALER[3:0]
rwrwrwrw
Bits 31:4Reserved, must be kept at reset value.
Bits 3:0

PRESCALER[3:0]: Clock prescaler.
The USART input clock can be divided by a prescaler:
0000: Input clock not divided
0001: Input clock divided by 2
0010: Input clock divided by 4
0011: Input clock divided by 6
0100: Input clock divided by 8
0101: Input clock divided by 10
0110: Input clock divided by 12
0111: Input clock divided by 16
1000: Input clock divided by 32
1001: Input clock divided by 64
1010: Input clock divided by 128
1011: Input clock divided by 256.
Remaining combinations: Reserved.
Note: When PRESCALER is programmed with a value different of the allowed ones, programmed prescaler value is «1011», i.e. input clock divided by 256.

23.5.11 LPUART register map

The table below gives the LPUART register map and reset values.

Table 108. LPUART register map and reset values

OffsetRegister313029282726252423222120191817161514131211109876543210
0x00LPUART_CR1RXFFIETXFEIEFIFOENM1Res.Res.DEAT[4:0]DEDT[4:0]Res.CMIEMMEM0WAKEPCEPSPEIETXEIETCIERXNEIEIDLEIETEREUESMUE
Reset value00000000000000000000000000000
0x04LPUART_CR2ADD[7:4]ADD[3:0]Res.Res.Res.Res.MSBFIRSTDATAINVTXINVRXINVSWAPRes.STOP [1:0]Res.Res.Res.Res.Res.Res.Res.ADDMM7Res.Res.Res.Res.
Reset value00000000000000000
0x08LPUART_CR3TXFTCF G[2:0]RXFTIERXFTCF G[2:0]Res.TXFTIEWUFIEWUS [1:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.HDSELRes.Res.EIE
Reset value00000000000000000000000
0x0CLPUART_BRRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value000000000000000
0x10-
0x14
Reserved
0x18LPUART_RQRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TXFRQTXFRQMMRQSBKRQ
Reset value0000
0x1CLPUART_ISRRes.Res.Res.Res.Res.Res.Res.Res.Res.REACKTEACKWUFRWUSBKFCMFBUSYRes.Res.Res.Res.Res.CTSCTSIFRes.TXETCRXNEIDLEORENFFEPE
Reset value00000000010000000
0x20LPUART_ICRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WUCFRes.Res.CMCFRes.Res.Res.Res.Res.Res.Res.CTSCFRes.Res.TCCFRes.IDLECFORECFNECFFE CFPECF
Reset value000000000
STMicroelectronics logo
STMicroelectronics logo
OffsetRegister313029282726252423222120191817161514131211109876543210
0x24LPUART_RDRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.RDR[8:0]
Reset value00000000
0x28LPUART_TDRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.TDR[8:0]
Reset value00000000
0x2CLPUART_PRESCRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PRESCALER[3:0]
Reset value0000

Refer to Section 2.2.2: Memory map and register boundary addresses.

STMicroelectronics logo
STMicroelectronics logo