34. Low-power universal asynchronous receiver transmitter (LPUART)

This section describes the low-power universal asynchronous receiver transmitter (LPUART).

34.1 LPUART introduction

The LPUART is an UART which enables bidirectional UART communications with a limited power consumption. Only 32.768 kHz LSE clock is required to enable UART communications up to 9600 baud. Higher baud rates can be reached when the LPUART is clocked by clock sources different from the LSE clock.

Even when the device is in low-power mode, the LPUART can wait for an incoming UART frame while having an extremely low energy consumption. The LPUART includes all 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.

34.2 LPUART main features

34.3 LPUART implementation

The table(s) below describe(s) LPUART implementation. It(they) also include(s) USARTs for comparison.

Table 194. Instance implementation on STM32G0x1

USART / LPUART instancesSTM32G0x31xx, STM32G0x41xx, STM32G0x51xx, STM32G0x61xxSTM32G0x71xx, STM32G0x81xxSTM32G0xB1xx, STM32G0xC1xx
USART1FULLFULLFULL
USART2BASICFULLFULL
USART3-BASICFULL
USART4-BASICBASIC
USART5--BASIC
USART6--BASIC
LPUART1LPLPLP
LPUART2--LP

Table 195. USART / LPUART features

USART / LPUART modes/features (1)Full feature setBasic feature setLow-power feature set
Hardware flow control for modemXXX
Continuous communication using DMAXXX
Multiprocessor communicationXXX
Synchronous mode (Master/Slave)XX-
Smartcard modeX--
Single-wire half-duplex communicationXXX
IrDA SIR ENDEC blockX--
LIN modeX--
Dual clock domain and wake-up from low-power modeX-X
Receiver timeout interruptX--
Modbus communicationX--
Auto baud rate detectionX--
Driver EnableXXX
USART data length7, 8 and 9 bits
Tx/Rx FIFOX-X
Tx/Rx FIFO size8-8
PrescalerX-X
Wake-up from low-power modeX (2)-X (2)

1. X = supported.

2. Wake-up supported from Stop 0 and Stop 1 modes.

34.4 LPUART functional description

34.4.1 LPUART block diagram

Figure 341. LPUART block diagram

Figure 341. LPUART block diagram. The diagram shows the internal architecture of the LPUART block. It is divided into two clock domains: the lpuart_pclk clock domain (for the peripheral bus interface) and the lpuart_ker_ck clock domain (for the core logic). The 32-bit APB bus connects to the COM Controller, which contains registers LPUART_CR1, LPUART_ISR, LPUART_CR2, LPUART_CR3, LPUART_RQR, LPUART_ICR, and LPUART_TDR. The COM Controller also connects to the IRQ Interface and DMA Interface. The lpuart_pclk clock domain includes the lpuart_wkup, lpuart_it, lpuart_tx_dma, and lpuart_rx_dma signals. The lpuart_ker_ck clock domain includes the lpuart_pclk, lpuart_ker_ck, and lpuart_ker_ck_pres signals. The COM Controller connects to the Tx/FIFO and Rx/FIFO blocks, which in turn connect to the TX Shift Reg and RX Shift Reg blocks. The TX Shift Reg and RX Shift Reg blocks connect to the TX and RX pins. The Baudrate generator & oversampling block connects to the TX Shift Reg and RX Shift Reg blocks. The Hardware flow control block connects to the CTS, RTS/DE, TX, and RX pins. The diagram is labeled MSV40858V4.
Figure 341. LPUART block diagram. The diagram shows the internal architecture of the LPUART block. It is divided into two clock domains: the lpuart_pclk clock domain (for the peripheral bus interface) and the lpuart_ker_ck clock domain (for the core logic). The 32-bit APB bus connects to the COM Controller, which contains registers LPUART_CR1, LPUART_ISR, LPUART_CR2, LPUART_CR3, LPUART_RQR, LPUART_ICR, and LPUART_TDR. The COM Controller also connects to the IRQ Interface and DMA Interface. The lpuart_pclk clock domain includes the lpuart_wkup, lpuart_it, lpuart_tx_dma, and lpuart_rx_dma signals. The lpuart_ker_ck clock domain includes the lpuart_pclk, lpuart_ker_ck, and lpuart_ker_ck_pres signals. The COM Controller connects to the Tx/FIFO and Rx/FIFO blocks, which in turn connect to the TX Shift Reg and RX Shift Reg blocks. The TX Shift Reg and RX Shift Reg blocks connect to the TX and RX pins. The Baudrate generator & oversampling block connects to the TX Shift Reg and RX Shift Reg blocks. The Hardware flow control block connects to the CTS, RTS/DE, TX, and RX pins. The diagram is labeled MSV40858V4.

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

The lpuart_pclk clock signal feeds the peripheral bus interface. It must be active when accesses to the LPUART registers are required.

The lpuart_ker_ck is the LPUART clock source. It is independent of the lpuart_pclk and delivered by the RCC. So, the LPUART registers can be written/read even when the lpuart_ker_ck is stopped.

When the dual clock domain feature is disabled, the lpuart_ker_ck is the same as the lpuart_pclk clock.

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.

34.4.2 LPUART signals

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

When the transmitter is disabled, the output pin returns to its I/O port configuration. When the transmitter is enabled and nothing is to be transmitted, the TX pin is at high level. In single-wire mode, this I/O is used to transmit and receive the data.

RS232 hardware flow control mode

The following pins are required in RS232 hardware flow control mode:

RS485 hardware flow control mode

The following pin is required in RS485 hardware control mode:

Note: DE and RTS share the same pin.

Refer to Table 196 and Table 197 for the list of USART input/output pins and internal signals.

Table 196. LPUART input/output pins

Pin nameSignal typeDescription
LPUART_RXInputSerial data receive input
LPUART_TXOutputTransmit data output
LPUART_CTSInputClear to send
LPUART_RTSOutputRequest to send
LPUART_DE (1)OutputDriver enable
  1. 1. LPUART_DE and LPUART_RTS share the same pin.

Description of USART input/output signals

Table 197. LPUART internal input/output signals

Pin nameSignal typeDescription
lpuart_pclkInputAPB clock
lpuart_ker_ckInputUSART kernel clock

Table 197. LPUART internal input/output signals (continued)

Pin nameSignal typeDescription
lpuart_wkupOutputUSART provides a wake-up interrupt
lpuart_itOutputUSART global interrupt
lpuart_tx_dmaInput/outputUSART transmit DMA request
lpuart_rx_dmaInput/outputUSART receive DMA request

34.4.3 LPUART character description

The word length can be set to 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 315 ).

By default, 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 transmission and reception clocks are generated when the enable bit is set for the transmitter and receiver, respectively.

The details of each block is given below.

Figure 342. LPUART word length programming

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

The diagram illustrates the timing for three different word lengths with one stop bit. Each section shows a 'Data frame', an 'Idle frame', and a 'Break frame' relative to a 'Clock' signal.

** LBCL bit controls last data clock pulse

MS33194V2

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

34.4.4 LPUART FIFOs and thresholds

The LPUART can operate in FIFO mode.

The LPUART comes with a Transmit FIFO (TXFIFO) and a Receive FIFO (RXFIFO). The FIFO mode is enabled by setting FIFOEN bit (bit 29) in LPUART_CR1 register.

Since the maximum data word length is 9 bits, the TXFIFO is 9-bit wide. However the RXFIFO default width is 12 bits. This is due to the fact that the receiver does not only store

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 together with the corresponding flags. However, only the data are read when reading the RDR.

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 interrupts are triggered. These thresholds are programmed through RXFTCFG and TXFTCFG bitfields in LPUART_CR3 control register.

In this case:

This means that the RXFIFO is filled until the number of data in the RXFIFO is equal to the programmed threshold.

RXFTCFG data have been received: one data in LPUART_RDR and (RXFTCFG - 1) data in the RXFIFO. As an example, when the RXFTCFG is programmed to '101', the RXFT flag is set when a number of data corresponding to the FIFO size has been received: FIFO size - 1 data in the RXFIFO and 1 data in the LPUART_RDR. As a result, the next received data does not set the overrun flag.

This means that the TXFIFO is emptied until the number of empty locations in the TXFIFO is equal to the programmed threshold.

34.4.5 LPUART 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 341 ).

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

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

The number of stop bits can be 1 or 2.

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

The TE bit should not be reset during data transmission. Resetting the TE bit during the transmission corrupts the data on the TX pin as the baud rate counters is frozen. The current data being transmitted are 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 LPUART_CR2 (bits 13,12).

An idle frame transmission includes the stop bits.

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 343. Configurable stop bits

Figure 343. Configurable stop bits. The diagram shows two timing diagrams for 8-bit word length (M[1:0]=00). Part (a) shows '1 Stop bit' configuration, where the frame consists of a Start bit, 8 Data bits (Bit0-Bit7), a Possible parity bit, a Stop bit, and a Next start bit. Part (b) shows '2 Stop bits' configuration, where the frame consists of a Start bit, 8 Data bits (Bit0-Bit7), a Possible parity bit, 2 Stop bits, and a Next start bit. Both diagrams include a CLOCK signal and a note that the LBCL bit controls the last data clock pulse. The diagram is labeled MS31885V1.

8-bit Word length (M[1:0]=00 bit is reset)

a) 1 Stop bit

CLOCK

Start bit    Data frame (Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7)    Possible parity bit    Stop bit    Next start bit    Next data frame

** LBCL bit controls last data clock pulse

b) 2 Stop bits

Start bit    Data frame (Bit0 Bit1 Bit2 Bit3 Bit4 Bit5 Bit6 Bit7)    Possible parity bit    2 Stop bits    Next start bit    Next data frame

MS31885V1

Figure 343. Configurable stop bits. The diagram shows two timing diagrams for 8-bit word length (M[1:0]=00). Part (a) shows '1 Stop bit' configuration, where the frame consists of a Start bit, 8 Data bits (Bit0-Bit7), a Possible parity bit, a Stop bit, and a Next start bit. Part (b) shows '2 Stop bits' configuration, where the frame consists of a Start bit, 8 Data bits (Bit0-Bit7), a Possible parity bit, 2 Stop bits, and a Next start bit. Both diagrams include a CLOCK signal and a note that the LBCL bit controls the last data clock pulse. The diagram is labeled MS31885V1.

Character transmission procedure

To transmit a character, follow the sequence below:

  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 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 34.4.12: Continuous communication using DMA and LPUART .
  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 operation 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. Write operations to the LPUART_TDR are performed when TXFNF flag is set. This flag remains set until the TXFIFO is full.
  8. 8. When the last data is written to the LPUART_TDR register, wait until TC = 1. This indicates that the transmission of the last frame is complete.
    • – When FIFO mode is disabled, this indicates that the transmission of the last frame is complete.

This check is required to avoid corrupting the last transmission when the LPUART is disabled or enters Halt mode.

Single byte communication

Writing to the transmit data register always clears the TXE bit. The TXE flag is set by hardware to indicate that:

The TXE flag generates an interrupt if the TXEIE bit is set.

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

When no transmission is ongoing, 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 to the 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 is 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 device to enter the low-power mode (see Figure 344: TC/TXE behavior when transmitting ).

Figure 344. TC/TXE behavior when transmitting

Timing diagram showing TX line, TXE flag, LPUART_DR, and TC flag signals during transmission of three frames (Frame 1, Frame 2, Frame 3) after an idle preamble. The diagram illustrates the software interaction with the TXE and TC flags for data writing and transmission completion detection.

The diagram illustrates the timing and flag behavior for transmitting three frames (Frame 1, Frame 2, Frame 3) after an idle preamble. The signals shown are TX line, TXE flag, LPUART_DR, and TC flag.

Software interaction:

MSv31889V1

Timing diagram showing TX line, TXE flag, LPUART_DR, and TC flag signals during transmission of three frames (Frame 1, Frame 2, Frame 3) after an idle preamble. The diagram illustrates the software interaction with the TXE and TC flags for data writing and transmission completion detection.

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 342 ).

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.

34.4.6 LPUART 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 the LPUART, the start bit is detected when a falling edge occurs on the Rx line, followed by a sample 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 (NE) is set, then the start bit is discarded and the receiver waits for a new start bit. Else, the receiver continues to sample all incoming bits normally.

Character reception

During an LPUART reception, data are shifted 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

To receive a character, follow the sequence below:

  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 LPUART_CR1 register to '1'.
  5. 5. Select DMA enable (DMAR) in LPUART_CR3 if multibuffer communication is to take place. Configure the DMA register as explained in Section 34.4.12: Continuous communication using DMA and LPUART .
  6. 6. Set the RE bit LPUART_CR1. This enables the receiver which begins searching for a start bit.

When a character is received

Alternatively, interrupts can be generated and data can be read from RXFIFO when the RXFIFO threshold is reached. In this case, the CPU can read a block of data defined by the programmed threshold.

Break character

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

Idle character

When an idle frame is detected, it is handled in the same way as a data character reception except that an interrupt is generated if the IDLEIE bit is set.

Overrun error

An overrun error occurs when a character is received when RXNE has not been reset. Data can not be transferred from the shift register to the RDR register until the RXNE bit is cleared. The RXNE flag is set after every byte received.

An overrun error occurs if RXNE flag is set when the next data is received or the previous DMA request has not been serviced. When an overrun error occurs:

An overrun error occurs when the shift register is ready to be transferred when the receive FIFO is full.

Data can not be transferred from the shift register to the LPUART_RDR register until there is one free location in the RXFIFO. The RXFNE flag is set when the RXFIFO is not empty.

An overrun error occurs if the RXFIFO is full and the shift register is ready to be transferred. When an overrun error occurs:

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. T

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 Reset and clock controller (RCC) ). The clock source must be selected through the UE bit, before enabling the LPUART.

The clock source must be selected according to two criteria:

The clock source frequency is lpuart_ker_ck.

When the dual clock domain and the wake-up from low-power mode features are supported, the lpuart_ker_ck clock source can be configured in the RCC (see Section Reset and clock controller (RCC) ). Otherwise, the lpuart_ker_ck is the same as lpuart_pclk.

The lpuart_ker_ck can be divided by a programmable factor in the LPUART_PRESC register.

Figure 345. lpuart_ker_ck clock divider block diagram

Block diagram of the lpuart_ker_ck clock divider. The input lpuart_ker_ck enters a block containing LPUARTx_PRESC[3:0] and LPUARTx_BRR register and oversampling. The output is lpuart_ker_ck_pres. The diagram is labeled MSv40859V1.
graph LR
    subgraph Block [ ]
        direction LR
        A[LPUARTx_PRESC[3:0]] -- lpuart_ker_ck_pres --> B[LPUARTx_BRR register and oversampling]
    end
    lpuart_ker_ck --> A
    style Block fill:none,stroke:none
    style lpuart_ker_ck_pres stroke:none,stroke-width:0px
    style MSv40859V1 fill:none,stroke:none
  
Block diagram of the lpuart_ker_ck clock divider. The input lpuart_ker_ck enters a block containing LPUARTx_PRESC[3:0] and LPUARTx_BRR register and oversampling. The output is lpuart_ker_ck_pres. The diagram is labeled MSv40859V1.

Some lpuart_ker_ck sources enable the LPUART to receive data while the MCU is in low-power mode. Depending on the received data and wake-up 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 to enable LPUART communications.

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

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

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:

multibuffer communication, an interrupt is issued if the EIE bit is set in the LPUART_CR3 register.

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 control bits of LPUART_CR2: it can be either 1 or 2 in normal mode.

34.4.7 LPUART baud rate generation

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

\[ \text{Tx/Rx baud} = \frac{256 \times \text{lpuartckpres}}{\text{LPUARTDIV}} \]

LPUARTDIV is defined in 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 lower than 0x300 in the LPUART_BRR register.

\( f_{CK} \) must range from 3 x baud rate to 4096 x baud rate.

The maximum baud rate that can be reached when the LPUART clock source is the LSE, is 9600 baud. Higher baud rates can be reached when the LPUART is clocked by clock sources different from the LSE clock. For example, if the LPUART clock source frequency is 100 MHz, the maximum baud rate that can be reached is about 33 Mbaud.

Table 198. Error calculation for programmed baud rates at lpuart_ker_ck_pres = 32.768 kHz

Baud ratelpuart_ker_ck_pres = 32.768 kHz
S.NoDesiredActualValue programmed in the baud rate register% Error = (Calculated - Desired) B.rate / Desired B.rate
1300 bauds300 baud0x6D3A0
2600 baud600 baud0x369D0
31200 baud1200.087 baud0x1B4E0.007
42400 baud2400.17 baud0xDA70.007
54800 baud4801.72 baud0x6D30.035
69600 baud9608.94 baud0x3690.093
Table 199. Error calculation for programmed baud rates at \( f_{CK} = 100 \) MHz
Baud rate\( f_{CK} = 100\text{MHz} \)
S.NoDesiredActualValue programmed in the baud rate register% Error = (Calculated - Desired) B.rate / Desired B.rate
138400 Baud38400,04 BaudA2C2A0,0001
257600 Baud57600,06 Baud6C81C0,0001
3115200 Baud115200,12 Baud3640E0,0001
4230400 Baud230400,23 Baud1B2070,0001
5460800 Baud460804,61 BaudD9030,001
6921600 Baud921625,81 Baud6C810,0028
74000 KBaud4000000,00 Baud19000
810000 Kbaud10000000,00 BaudA000
920000 Kbaud20000000,00 Baud5000
1033000 Kbaud33032258,06 Baud3070,1

34.4.8 Tolerance of the LPUART receiver to clock deviation

The asynchronous receiver of the LPUART works correctly only if the total clock system deviation is less than the tolerance of the LPUART receiver. The causes which contribute to the total deviation are:

\[ DTRA + DQUANT + DREC + DTCL + DWU < \text{LPUART receiver tolerance} \]

where

DWU is the error due to sampling point deviation when the wake-up from low-power mode is used.

The LPUART receiver can receive data correctly at up to the maximum tolerated deviation specified in Table 200 :

Table 200. Tolerance of the LPUART receiver

M bits768 < BRR < 10241024 < BRR < 20482048 < BRR < 40964096 ≤ BRR
8 bits (M = '00'), 1 Stop bit1.82%2.56%3.90%4.42%
9 bits (M = '01'), 1 Stop bit1.69%2.33%2.53%4.14%
7 bits (M = '10'), 1 Stop bit2.08%2.86%4.35%4.42%
8 bits (M = '00'), 2 Stop bit2.08%2.86%4.35%4.42%
9 bits (M = '01'), 2 Stop bit1.82%2.56%3.90%4.42%
7 bits (M = '10'), 2 Stop bit2.34%3.23%4.92%4.42%

Note: The data specified in Table 200 may slightly differ in the special case when the received frames contain some Idle frames of exactly 10-bit times when M bits = '00' (11-bit times when M = '01' or 9- bit times when M = '10').

34.4.9 LPUART multiprocessor communication

It is possible to perform LPUART multiprocessor communications (with several LPUARTs connected in a network). For instance one of the LPUARTs can be the master, with its TX output connected to the RX inputs of the other LPUARTs. The others are slaves, with 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 actively receives the full message contents, thus reducing redundant LPUART service overhead for all non addressed receivers.

The non addressed devices can be placed in mute mode by means of the muting function. 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 lpuart_ker_ck cycles), otherwise mute mode might remain active.

When the mute mode is enabled:

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.

The LPUART wakes up when an Idle frame is detected. The RWU bit is then 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 346 .

Figure 346. Mute mode using Idle line detection

Timing diagram illustrating Mute mode using Idle line detection. The RX line shows a sequence of data frames: Data 1, Data 2, Data 3, Data 4, followed by an IDLE frame, then Data 5, and Data 6. The RWU line shows the transition from Normal mode to Mute mode when MMRQ is written to 1, and back to Normal mode when an Idle frame is detected. The RXNE flag is shown pulsing for Data 5 and Data 6.

The diagram shows two horizontal timelines. The top timeline, labeled 'RX', shows a sequence of data frames: 'Data 1', 'Data 2', 'Data 3', 'Data 4', followed by an 'IDLE' frame, then 'Data 5', and 'Data 6'. Above 'Data 5' and 'Data 6', there are arrows pointing to the RXNE flag, indicating that the RXNE flag is set for these frames. The bottom timeline, labeled 'RWU', shows the state of the RWU bit. It starts at a low level, then jumps to a high level when 'MMRQ written to 1' occurs, entering 'Mute mode'. It returns to a low level when 'Idle frame detected' occurs, returning to 'Normal mode'. The text 'MSv31154V1' is in the bottom right corner.

Timing diagram illustrating Mute mode using Idle line detection. The RX line shows a sequence of data frames: Data 1, Data 2, Data 3, Data 4, followed by an IDLE frame, then Data 5, and Data 6. The RWU line shows the transition from Normal mode to Mute mode when MMRQ is written to 1, and back to Normal mode when an Idle frame is detected. The RXNE flag is shown pulsing for Data 5 and Data 6.

Note: If the MMRQ is set while the IDLE character has already elapsed, the 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 347 .

Figure 347. Mute mode using address mark detection

Timing diagram showing RX and RWU signals. RX shows a sequence of IDLE, Addr=0, Data 1, Data 2, IDLE, Addr=1, Data 3, Data 4, Addr=2, Data 5. RWU shows Mute mode, Normal mode, and Mute mode segments. RXNE flags are shown above the RX signal. Annotations include 'MMRQ written to 1 (RXNE was cleared)', 'Non-matching address', 'Matching address', and 'Non-matching address'.

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

MSv31888V1

Timing diagram showing RX and RWU signals. RX shows a sequence of IDLE, Addr=0, Data 1, Data 2, IDLE, Addr=1, Data 3, Data 4, Addr=2, Data 5. RWU shows Mute mode, Normal mode, and Mute mode segments. RXNE flags are shown above the RX signal. Annotations include 'MMRQ written to 1 (RXNE was cleared)', 'Non-matching address', 'Matching address', and 'Non-matching address'.

34.4.10 LPUART 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 201 .

Table 201: LPUART frame formats

M bitsPCE bitLPUART frame (1)
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 | 7bit data | STB |
101| SB | 6-bit data | PB | STB |

1. Legends: SB: start bit, STB: stop bit, PB: parity bit.

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

Even parity

The parity bit is calculated to obtain an even number of “1s” 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 equal 00110101, and 4 bits are set, then the parity bit is equal to 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 “1s” 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 equal 00110101 and 4 bits set, then the parity bit is equal to 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 “1s” if even parity is selected (PS = 0) or an odd number of “1s” if odd parity is selected (PS = 1)).

34.4.11 LPUART 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 conflict on the line must be managed by software (for instance by using a centralized arbiter). 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 communications, in the case of 1-stop bit configuration, the RXNE flag is set in the middle of the stop bit.

34.4.12 Continuous communication using DMA and LPUART

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 33.4: USART implementation on page 986 to determine if the DMA mode is supported. If DMA is not supported, use the LPUSRT as explained in Section 33.5.6 . To perform continuous communication. When FIFO is disabled, you can clear the TXE/ RXNE flags in the LPUART_ISR register.

Transmission using DMA

DMA mode can be enabled for transmission by setting DMAT bit in the LPUART_CR3 register. Data are loaded from an SRAM area configured using the DMA peripheral (refer to the corresponding Direct memory access controller section ) 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 low-power 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 348. Transmission using DMA

Timing diagram for Figure 348. Transmission using DMA. The diagram shows the relationship between the TX line, TXE flag, DMA request, LPUART_TDR, TC flag, DMA writes, DMA transfer complete flag, and software actions over time for three frames (Frame 1, Frame 2, Frame 3).

The diagram illustrates the timing for DMA transmission of three frames (Frame 1, Frame 2, Frame 3) over an idle preamble. The signals shown are:

Software actions shown at the bottom:

  1. Software configures DMA to send 3 data blocks and enables LPUART.
  2. DMA writes F1 into LPUART_TDR.
  3. DMA writes F2 into LPUART_TDR.
  4. DMA writes F3 into LPUART_TDR.
  5. The DMA transfer is complete.
  6. Software waits until TC = 1.

MSv31890V4

Timing diagram for Figure 348. Transmission using DMA. The diagram shows the relationship between the TX line, TXE flag, DMA request, LPUART_TDR, TC flag, DMA writes, DMA transfer complete flag, and software actions 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 LPUART_CR3 register. Data are loaded from the LPUART_RDR register to a SRAM area configured using the DMA peripheral (refer to the corresponding Direct memory access controller (DMA) section ) 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 349. Reception using DMA

Timing diagram for Figure 349. Reception using DMA. The diagram shows the relationship between the RX line, RXNE flag, DMA request, LPUART_RDR, and DMA transfer complete flag over three frames (Frame 1, Frame 2, Frame 3).

The diagram illustrates the timing for reception using DMA across three frames (Frame 1, Frame 2, Frame 3). The signals shown are:

Annotations at the bottom of the diagram:

MSV31891V5

Timing diagram for Figure 349. Reception using DMA. The diagram shows the relationship between the RX line, RXNE flag, DMA request, LPUART_RDR, and DMA transfer complete flag over three frames (Frame 1, Frame 2, Frame 3).

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 multibuffer communication

If any error occurs during a transaction In multibuffer communication mode, 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.

34.4.13 RS232 hardware flow control and RS485 Driver Enable

It is possible to control the serial data flow between 2 devices by using the CTS input and the RTS output. The Figure 336 shows how to connect 2 devices in this mode:

Diagram showing hardware flow control between two LPUARTs. LPUART 1 has TX and RX circuits. LPUART 2 has RX and TX circuits. Connections: TX of LPUART 1 to RX of LPUART 2; RX of LPUART 1 to TX of LPUART 2; RTS of LPUART 1 to CTS of LPUART 2; CTS of LPUART 1 to RTS of LPUART 2.

Figure 350. Hardware flow control between 2 LPUARTs

The diagram illustrates the connection between two LPUART modules, LPUART 1 and LPUART 2, for hardware flow control. LPUART 1 contains a TX circuit and an RX circuit. LPUART 2 contains an RX circuit and a TX circuit. The connections are as follows:

MSv31892V2

Diagram showing hardware flow control between two LPUARTs. LPUART 1 has TX and RX circuits. LPUART 2 has RX and TX circuits. Connections: TX of LPUART 1 to RX of LPUART 2; RX of LPUART 1 to TX of LPUART 2; RTS of LPUART 1 to CTS of LPUART 2; CTS of LPUART 1 to RTS of LPUART 2.

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 RTS is deasserted (tied low) as long as the LPUART receiver is ready to receive a new data. When the receive register is full, RTS is asserted, indicating that the transmission is expected to stop at the end of the current frame. Figure 351 shows an example of communication with RTS flow control enabled.

Timing diagram for RS232 RTS flow control. The RX line shows two data frames: Start bit, Data 1, Stop bit, Idle, Start bit, Data 2, Stop bit. The RTS line is initially low. It goes high (asserted) when the first frame is received (RXNE flag). It goes low (deasserted) when Data 1 is read from the receive register. It goes high again when the second frame is received (RXNE flag). It goes low again when Data 2 is read.

Figure 351. RS232 RTS flow control

The diagram shows the relationship between the RX (Receive) line and the RTS (Request to Send) line during two data transmissions. The RX line shows the sequence: Start bit, Data 1, Stop bit, Idle, Start bit, Data 2, Stop bit. The RTS line is initially low. When the first frame (Data 1) is received, the RXNE (Receive Not Empty) flag is set, and the RTS line goes high (asserted). When Data 1 is read from the receive register, the RXNE flag is reset, and the RTS line goes low (deasserted). When the second frame (Data 2) is received, the RXNE flag is set again, and the RTS line goes high. When Data 2 is read, the RTS line goes low again. The text "Data 1 read Data 2 can now be transmitted" is shown between the two frames when the RTS line is low.

MSv68794V1

Timing diagram for RS232 RTS flow control. The RX line shows two data frames: Start bit, Data 1, Stop bit, Idle, Start bit, Data 2, Stop bit. The RTS line is initially low. It goes high (asserted) when the first frame is received (RXNE flag). It goes low (deasserted) when Data 1 is read from the receive register. It goes high again when the second frame is received (RXNE flag). It goes low again when Data 2 is read.

Note: When FIFO mode is enabled, RTS is asserted only when RXFIFO is full.

RS232 CTS flow control

If the CTS flow control is enabled (CTSE = 1), then the transmitter checks the CTS input before transmitting the next frame. If CTS is deasserted (tied low), then the next data is transmitted (assuming that data is to be transmitted, in other words, if TXE/TXFE = 0), else the transmission does not occur. When CTS is asserted 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 352 shows an example of communication with CTS flow control enabled.

Figure 352. RS232 CTS flow control

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

The diagram illustrates the timing for RS232 CTS flow control. It consists of three horizontal timelines:

The diagram is labeled with 'MSV68793V1' in the bottom right corner.

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

Note: For correct behavior, CTS must be deasserted 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 enables activating the external transceiver control, through the DE (Driver Enable) 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] bitfields 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 de-activation of the DE signal. It is programmed using the DEDT [4:0] bitfields 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.

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

where \( P = BRR[20:11] \)

34.4.14 LPUART low-power management

The LPUART has advanced low-power mode functions that enable it to transfer properly data even when the lpuart_pclk clock is disabled.

The LPUART is able to wake up the MCU from low-power mode when the UESM bit is set. When the lpuart_pclk is gated, the LPUART provides a wake-up interrupt ( lpuart_wkup ) if a specific action requiring the activation of the lpuart_pclk clock is needed:

This enables sending/receiving the data in the TXFIFO/RXFIFO during low-power mode.

To avoid overrun/underrun errors and transmit/receive data in low-power mode, the lpuart_wkup interrupt source can be one of the following events:

For example, the application can set the threshold to the maximum RXFIFO size if the wake-up time is less than the time to receive a single byte across the line.

Using the RXFIFO full, TXFIFO empty, RXFIFO not empty and RXFIFO/TXFIFO threshold interrupts to wake up the MCU from low-power mode enables doing as many LPUART transfers as possible during low-power mode with the benefit of optimizing consumption.

Alternatively, a specific lpuart_wkup interrupt may be selected through the WUS bitfields.

When the wake-up event is detected, the WUF flag is set by hardware and lpuart_wkup interrupt is generated if the WUFIE bit is set.

Note: Before entering low-power mode, make sure that no LPUART transfer is ongoing. Checking the BUSY flag cannot ensure that low-power mode is never entered when data reception is ongoing.

The WUF flag is set when a wake-up event is detected, independently of whether the MCU is in low-power or in an active mode.

When entering low-power mode just after having initialized and enabled the receiver, the REACK bit must be checked to ensure the LPUART is actually enabled.

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

When FIFO is enabled, the wake-up from low-power mode on address match is only possible when mute mode is enabled.

Using mute mode with low-power mode

If the LPUART is put into mute mode before entering low-power mode:

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

Wake-up from low-power mode when LPUART kernel clock lpuart_ker_ck is OFF in low-power mode

If during low-power mode, the lpuart_ker_ck clock is switched OFF, when a falling edge on the LPUART receive line is detected, the LPUART interface requests the lpuart_ker_ck clock to be switched ON thanks to the lpuart_ker_ck_req signal. The lpuart_ker_ck is then used for the frame reception.

If the wake-up event is verified, the MCU wakes up from low-power mode and data reception goes on normally.

If the wake-up event is not verified, the lpuart_ker_ck is switched OFF again, the MCU is not waken up and stays in low-power mode and the kernel clock request is released.

The example below shows the case of wake-up event programmed to “address match detection” and FIFO management disabled.

Figure 353 shows the behavior when the wake-up event is verified.

Figure 353. Wake-up event verified (wake-up event = address match, FIFO disabled)

Timing diagram for Figure 353 showing a wake-up event verified by an address match. The RX line shows an Idle state followed by a Start bit, Rx data 1, and a Stop bit. The LPUART sends a wake-up event to the MCU at the end of the Stop bit, indicated by 'Address match event WUF = '1''. The LPUART clock (lpuart_ker_ck) is OFF during the Idle state and turns ON at the Start bit. The MCU enters Low-power mode at the Idle state and switches to Run mode at the Start bit. Data reception continues with a second Start bit, Rx data 2, and a Stop bit. The diagram is labeled MSV40860V2.
Timing diagram for Figure 353 showing a wake-up event verified by an address match. The RX line shows an Idle state followed by a Start bit, Rx data 1, and a Stop bit. The LPUART sends a wake-up event to the MCU at the end of the Stop bit, indicated by 'Address match event WUF = '1''. The LPUART clock (lpuart_ker_ck) is OFF during the Idle state and turns ON at the Start bit. The MCU enters Low-power mode at the Idle state and switches to Run mode at the Start bit. Data reception continues with a second Start bit, Rx data 2, and a Stop bit. The diagram is labeled MSV40860V2.

Figure 354 shows the behavior when the wake-up event is not verified.

Figure 354. Wake-up event not verified (wake-up event = address match, FIFO disabled)

Timing diagram for Figure 354 showing a wake-up event not verified because the address does not match. The RX line shows an Idle state followed by a Start bit, Rx data 1, and a Stop bit. After the Stop bit, the line returns to Idle. The LPUART does not send a wake-up event, indicated by 'Address does not match'. The LPUART clock (lpuart_ker_ck) is OFF during the Idle state and turns ON at the Start bit. The MCU enters Low-power mode at the Idle state and switches to Run mode at the Start bit. After the Stop bit, the MCU returns to Low-power mode and the clock turns OFF. The diagram is labeled MSV40861V2.
Timing diagram for Figure 354 showing a wake-up event not verified because the address does not match. The RX line shows an Idle state followed by a Start bit, Rx data 1, and a Stop bit. After the Stop bit, the line returns to Idle. The LPUART does not send a wake-up event, indicated by 'Address does not match'. The LPUART clock (lpuart_ker_ck) is OFF during the Idle state and turns ON at the Start bit. The MCU enters Low-power mode at the Idle state and switches to Run mode at the Start bit. After the Stop bit, the MCU returns to Low-power mode and the clock turns OFF. The diagram is labeled MSV40861V2.

Note: The above figures are valid when address match or any received frame is used as wake-up event. In the case the wake-up event is the start bit detection, the LPUART sends the wake-up event to the MCU at the end of the start bit.

Determining the maximum LPUART baud rate that enables to correctly wake up the MCU from low-power mode

The maximum baud rate that enables to correctly wake up the MCU from low-power mode depends on the wake-up time parameter (refer to the device datasheet) and on the LPUART receiver tolerance (see Section 34.4.8: Tolerance of the LPUART receiver to clock deviation ).

Let us take the example of OVER8 = 0, M bits = '01', ONEBIT = 0 and BRR [3:0] = 0000.

In these conditions, according to Table 200: Tolerance of the LPUART receiver , the LPUART receiver tolerance equals 3.41%.

\[ DTRA + DQUANT + DREC + DTCL + DWU < \text{LPUART receiver tolerance} \]

\[ D_{WUmax} = t_{WULPUART} / (11 \times T_{bit\ Min}) \]

\[ T_{bit\ Min} = t_{WULPUART} / (11 \times D_{WUmax}) \]

where \( t_{WULPUART} \) is the wake-up time from low-power mode.

If we consider the ideal case where DTRA, DQUANT, DREC and DTCL parameters are at 0%, the maximum value of DWU is 3.41%. In reality, we need to consider at least the lpuart_ker_ck inaccuracy.

For example, if HSI is used as lpuart_ker_ck , and the HSI inaccuracy is of 1%, then we obtain:

\[ t_{WULPUART} = 3\ \mu\text{s} \text{ (values provided only as examples; for correct values, refer to the device datasheet).} \]

\[ D_{WUmax} = 3.41\% - 1\% = 2.41\% \]

\[ T_{bit\ min} = 3\ \mu\text{s} / (11 \times 2.41\%) = 11.32\ \mu\text{s}. \]

As a result, the maximum baud rate that enables to wake up correctly from low-power mode is: \( 1/11.32\ \mu\text{s} = 88.36\ \text{kbaud} \) .

34.5 LPUART in low-power modes

Table 202. Effect of low-power modes on the LPUART

ModeDescription
SleepNo effect. LPUART interrupts cause the device to exit Sleep mode.
Stop (1)The content of the LPUART registers is kept.
The LPUART is able to wake up the microcontroller from Stop mode when the LPUART is clocked by an oscillator available in Stop mode.
StandbyThe LPUART peripheral is powered down and must be reinitialized after exiting Standby mode.
  1. Refer to Section 34.3: LPUART implementation to know if the wake-up from Stop mode is supported for a given peripheral instance. If an instance is not functional in a given Stop mode, it must be disabled before entering this Stop mode.

34.6 LPUART interrupts

Refer to Table 203 for a detailed description of all LPUART interrupt requests.

Table 203. LPUART interrupt requests

Interrupt vectorInterrupt eventEvent flagEnable Control bitInterrupt clear methodExit from Sleep modeExit from Stop (1) modesExit from Standby mode
LPUARTTransmit data register emptyTXETXEIEWrite TDRYesNoNo
Transmit FIFO Not FullTXFNFTXFNFIETXFIFO fullNo
Transmit FIFO EmptyTXFETXFEIEWrite TDR or write 1 in TXFRQYes
Transmit FIFO threshold reachedTXFTTXFTIEWrite TDRYes
CTS interruptCTSIFCTSIEWrite 1 in CTSCFNo
Transmission CompleteTCTCIEWrite TDR or write 1 in TCCFNo
Receive data register not empty (data ready to be read)RXNERXNEIERead RDR or write 1 in RXFRQYesYes
Receive FIFO Not EmptyRXFNERXFNEIERead RDR until RXFIFO empty or write 1 in RXFRQYes
Receive FIFO FullRXFF (2)RXFFIERead RDRYes
Receive FIFO threshold reachedRXFTRXFTIERead RDRYes
Overrun error detectedORERXNEIE/RXFNEIEWrite 1 in ORECFNo
Idle line detectedIDLEIDLEIEWrite 1 in IDLECFNo
Parity errorPEPEIEWrite 1 in PECFNo
Noise error in multibuffer communication.NEEIEWrite 1 in NFCFNo
Overrun error in multibuffer communication.ORE (3)Write 1 in ORECFNo
Framing Error in multibuffer communication.FEWrite 1 in FECFNo
Character matchCMFCMIEWrite 1 in CMCFNo
Wake-up from low-power modeWUFWUFIEWrite 1 in WUCYes
  1. 1. The LPUART can wake up the device from Stop mode only if the peripheral instance supports the wake-up from Stop mode feature. Refer to Section 34.3: LPUART implementation for the list of supported Stop modes.
  2. 2. 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 Stop 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).
  3. 3. When OVRDIS = 0.

34.7 LPUART registers

Refer to Section 1.2 on page 55 for a list of abbreviations used in register descriptions.

The peripheral registers have to be accessed by words (32 bits).

34.7.1 LPUART control register 1 (LPUART_CR1)

Address offset: 0x00

Reset value: 0x0000 0000

The same register can be used in FIFO mode enabled (this section) and FIFO mode disabled (next section).

FIFO mode enabled

31302928272625242322212019181716
RXF
FIE
TXFEIEFIFO
EN
M1Res.Res.DEAT[4:0]DEDT[4:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.CMIEMMEM0WAKEPCEPSPEIETXFN
FIE
TCIERXFN
EIE
IDLEIETEREUESMUE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 RXFIE :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

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

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 must be used in conjunction with bit 12 (M0) to determine 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-bit data length mode, the smartcard mode, LIN master mode and Auto baud rate (0x7F and 0x55 frames detection) are not supported.

Bits 27:26 Reserved, 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 lpuart_ker_ck clock cycles. For more details, refer Section 33.5.20: RS232 hardware flow control and RS485 Driver Enable .

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

Bits 20:16 DEDT[4:0]: Driver enable deassertion 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 lpuart_ker_ck clock cycles. For more details, refer Section 34.4.13: RS232 hardware flow control and RS485 Driver Enable .

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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 15 Reserved, must be kept at reset value.

Bit 14 CMIE: Character match interrupt enable

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A LPUART interrupt is generated when the CMF bit is set in the LPUART_ISR register.

Bit 13 MME: 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 12 M0: Word length

This bit is used in conjunction with bit 28 (M1) to determine the word length. It is set or cleared by software (refer to bit 28 (M1) description).

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

Bit 11 WAKE: Receiver wake-up method

This bit determines the LPUART wake-up method from mute mode. It is set or cleared by software.

0: Idle line

1: Address mark

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

Bit 10 PCE: 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 9 PS: 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 8 PEIE: 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 7 TXFNIE: TXFIFO not full interrupt enable

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A LPUART interrupt is generated whenever TXE/TXFNF = 1 in the LPUART_ISR register

Bit 6 TCIE: 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 5 RXFNIE: RXFIFO not empty interrupt enable

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A 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 low 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 Stop mode

When this bit is cleared, the LPUART is not able to wake up the MCU from low-power mode.

When this bit is set, the LPUART is able to wake up the MCU from low-power mode, provided that the LPUART clock selection is HSI or LSE in the RCC.

This bit is set and cleared by software.

0: LPUART not able to wake up the MCU from low-power mode.

1: LPUART able to wake up the MCU from low-power mode. When this function is active, the clock source for the LPUART must be HSI or LSE (see RCC chapter)

Note: It is recommended to set the UESM bit just before entering low-power mode and clear it on exit from low-power 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: To enter 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.

34.7.2 LPUART control register 1 [alternate] (LPUART_CR1)

Address offset: 0x00

Reset value: 0x0000 0000

The same register can be used in FIFO mode enabled (previous section) and FIFO mode disabled (this section).

FIFO mode disabled

31302928272625242322212019181716
Res.Res.FIFO ENM1Res.Res.DEAT[4:0]DEDT[4:0]
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.CMIEMMEM0WAKEPCEPSPEIETXEIETCIERXNEIEIDLEIETEREUESMUE
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:30 Reserved, 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 must be used in conjunction with bit 12 (M0) to determine 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-bit data length mode, the smartcard mode, LIN master mode and Auto baud rate (0x7F and 0x55 frames detection) are not supported.

Bits 27:26 Reserved, 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 lpuart_ker_ck clock cycles. For more details, refer Section 33.5.20: RS232 hardware flow control and RS485 Driver Enable .

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

Bits 20:16 DEDT[4:0]: Driver enable deassertion 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 lpuart_ker_ck clock cycles. For more details, refer Section 34.4.13: RS232 hardware flow control and RS485 Driver Enable .

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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 15 Reserved, must be kept at reset value.

Bit 14 CMIE: Character match interrupt enable

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A LPUART interrupt is generated when the CMF bit is set in the LPUART_ISR register.

Bit 13 MME: 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 12 M0: Word length

This bit is used in conjunction with bit 28 (M1) to determine the word length. It is set or cleared by software (refer to bit 28 (M1) description).

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

Bit 11 WAKE: Receiver wake-up method

This bit determines the LPUART wake-up method from mute mode. It is set or cleared by software.

0: Idle line

1: Address mark

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

Bit 10 PCE: 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 9 PS: 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bit 8 PEIE: 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 7 TXEIE: Transmit data register empty

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A LPUART interrupt is generated whenever TXE/TXFNF = 1 in the LPUART_ISR register

Bit 6 TCIE: 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 5 RXNEIE: Receive data register not empty

This bit is set and cleared by software.

0: Interrupt is inhibited

1: A 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 low 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 Stop mode

When this bit is cleared, the LPUART is not able to wake up the MCU from low-power mode. When this bit is set, the LPUART is able to wake up the MCU from low-power mode, provided that the LPUART clock selection is HSI or LSE in the RCC.

This bit is set and cleared by software.

0: LPUART not able to wake up the MCU from low-power mode.

1: LPUART able to wake up the MCU from low-power mode. When this function is active, the clock source for the LPUART must be HSI or LSE (see RCC chapter)

Note: It is recommended to set the UESM bit just before entering low-power mode and clear it on exit from low-power 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: To enter 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.

34.7.3 LPUART control register 2 (LPUART_CR2)

Address offset: 0x04

Reset value: 0x0000 0000

31302928272625242322212019181716
ADD[7:0]Res.Res.Res.Res.MSBFI
RST
DATAIN
V
TXINVRXINV
rwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SWAPRes.STOP[1:0]Res.Res.Res.Res.Res.Res.Res.ADD7Res.Res.Res.Res.
rwrwrwrw
Bits 31:24 ADD[7:0] : Address of the LPUART node

These bits give the address of the LPUART node in mute mode or a character code to be recognized in low-power or Run mode:

These bits can only be written when the reception is disabled (RE = 0) or when the USART is disabled (UE = 0).

Bits 23:20 Reserved, 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 bitfield 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 send/received in positive/direct logic. (1 = H, 0 = L)

1: Logical data from the data register are send/received in negative/inverse logic. (1 = L, 0 = H).

The parity bit is also inverted.

This bitfield 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 ( \( V_{DD} = 1/\text{idle} \) , Gnd = 0/mark)

1: TX pin signal values are inverted ( \( V_{DD} = 0/\text{mark} \) , Gnd = 1/idle).

This enables the use of an external inverter on the TX line.

This bitfield 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 ( \( V_{DD} = 1/\text{idle} \) , Gnd = 0/mark)

1: RX pin signal values are inverted ( \( V_{DD} = 0/\text{mark} \) , Gnd = 1/idle).

This enables the use of an external inverter on the RX line.

This bitfield 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: The TX and RX pins functions are swapped. This enables to work in the case of a cross-wired connection to another UART.

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

Bit 14 Reserved, 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Bits 11:5 Reserved, 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:0 Reserved, must be kept at reset value.

34.7.4 LPUART control register 3 (LPUART_CR3)

Address offset: 0x08

Reset value: 0x0000 0000

31302928272625242322212019181716
TXFTCFG[2:0]RXFTIERXFTCFG[2:0]Res.TXFTIEWUFIEWUS[1:0]Res.Res.Res.Res.
rwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
DEPDEMDDREOVRDISRes.CTSIECTSERTSEDMATDMARRes.Res.HDSELRes.Res.EIE
rwrwrwrwrwrwrwrwrwrwrw

Bits 31:29 TXFTCFG[2:0] : 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[2:0] : 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: A LPUART interrupt is generated when TXFIFO reaches the threshold programmed in TXFTCFG.

Bit 22 WUFIE : Wake-up from low-power 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 low-power mode.

If the LPUART does not support the wake-up from Stop feature, this bit is reserved and must be kept at reset value. Refer to Section 33.4: USART implementation .

Bits 21:20 WUS[1:0] : Wake-up from low-power mode interrupt flag selection

This bitfield specifies the event which activates the WUF (wake-up from low-power 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 bitfield can only be written when the LPUART is disabled (UE = 0).

Note: If the LPUART does not support the wake-up from Stop feature, this bit is reserved and must be kept at reset value. Refer to Section 33.4: USART implementation .

Bits 19:16 Reserved, 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 enables 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 OVREDIS : 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 enables checking the communication flow w/o reading the data.

Bit 11 Reserved, 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 CTS input is deasserted (tied to 0). If the CTS input is asserted while data is being transmitted, then the transmission is completed before stopping. If data is written into the data register while CTS is asserted, the transmission is postponed until CTS is deasserted.

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 RTS output is deasserted (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 6 DMAR : DMA enable receiver

This bit is set/reset by software

1: DMA mode is enabled for reception

0: DMA mode is disabled for reception

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

Bit 3 HDSEL : 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).

Bits 2:1 Reserved, must be kept at reset value.

Bit 0 EIE : 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 NE = 1 in the LPUART_ISR register).

0: Interrupt is inhibited

1: An interrupt is generated when FE = 1 or ORE = 1 or NE = 1 in the LPUART_ISR register.

34.7.5 LPUART 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 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.BRR[19:16]
rwrwrwrw
1514131211109876543210
BRR[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:20 Reserved, must be kept at reset value.

Bits 19:0 BRR[19:0] : LPUART baud rate

Note: It is forbidden to write values lower than 0x300 in the LPUART_BRR register. Provided that LPUART_BRR must be \( \geq 0x300 \) and LPUART_BRR is 20 bits, a care should be taken when generating high baud rates using high fck values. fck must be in the range [3 x baud rate..4096 x baud rate].

34.7.6 LPUART request register (LPUART_RQR)

Address offset: 0x18

Reset value: 0x0000 0000

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.TXFRQRXFRQMMRQSBKRQRes.
wwww

Bits 31:5 Reserved, must be kept at reset value.

Bit 4 TXFRQ : 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 are written in the data register.

Bit 3 RXFRQ : Receive data flush request

Writing 1 to this bit clears the RXNE flag.

This enables discarding the received data without reading it, and avoid an overrun condition.

Bit 2 MMRQ : Mute mode request

Writing 1 to this bit puts the LPUART in mute mode and resets the RWU flag.

Bit 1 SBKRQ : 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: If 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 0 Reserved, must be kept at reset value.

34.7.7 LPUART interrupt and status register (LPUART_ISR)

Address offset: 0x1C

Reset value: 0x0080 00C0

The same register can be used in FIFO mode enabled (this section) and FIFO mode disabled (next section).

FIFO mode enabled

31302928272625242322212019181716
Res.Res.Res.Res.TXFTRXFTRes.RXFFTXFEREACKTEACKWUFRWUSBKFCMFBUSY
rrrrrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.CTSCTSIFRes.TXFNFTCRXFNEIDLEORENEFEPE
rrrrrrrrrr

Bits 31:28 Reserved, must be kept at reset value.

Bit 27 TXFT : TXFIFO threshold flag

This bit is set by hardware when the TXFIFO reaches the threshold programmed in TXFTCFG in LPUART_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 26 RXFT : RXFIFO threshold flag

This bit is set by hardware when the RXFIFO reaches the threshold programmed in RXFTCFG in LPUART_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 25 Reserved, must be kept at reset value.

Bit 24 RXFF : RXFIFO full

This bit is set by hardware when the number of received data corresponds to RXFIFO size + 1 (RXFIFO full + 1 data in the LPUART_RDR register.

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

0: RXFIFO is not full

1: RXFIFO is full

Bit 23 TXFE : 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 22 REACK : 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 low-power mode.

Note: If the LPUART does not support the wake-up from Stop feature, this bit is reserved and kept at reset value.

Bit 21 TEACK : 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 : Wake-up from low-power mode flag

This bit is set by hardware, when a wake-up event is detected. The event is defined by the WUS bitfield. 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.

If the LPUART does not support the wake-up from Stop feature, this bit is reserved and kept at reset value

Bit 19 RWU : Receiver wake-up from mute mode

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

When wake-up 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 wake-up from Stop feature, this bit is reserved and kept at reset value.

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: Break character transmitted

1: Break character requested by setting SBKRQ bit in LPUART_RQR register

Bit 17 CMF: Character match flag

This bit is set by hardware, when 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 ongoing 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:11 Reserved, 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 CTS input pin.

0: CTS line set

1: CTS line reset

Note: If the hardware flow control feature is not supported, this bit is reserved and kept at reset value.

Bit 9 CTSIF: CTS interrupt flag

This bit is set by hardware when the CTS 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 CTS status line

1: A change occurred on the CTS status line

Note: If the hardware flow control feature is not supported, this bit is reserved and kept at reset value.

Bit 8 Reserved, must be kept at reset value.

Bit 7 TXFNF: TXFIFO not full

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.

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 are set at the same time).

An interrupt is generated if the 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 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 RXFNE: RXFIFO not empty

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 RXFNE flag can also be cleared by writing 1 to the RXFRQ in the LPUART_RQR register.

An interrupt is generated if 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 RXFNE 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 LPUART_RDR register while RXFF = 1. It is cleared by a software, writing 1 to the ORECF, in the LPUART_ICR register.

An interrupt is generated if RXFNEIE = 1 or EIE = 1 in the LPUART_CR1 register, or EIE = 1 in the LPUART_CR3 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 OVRRDIS is set in the LPUART_CR3 register.

Bit 2 NE: 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 NECF 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 RXFNE bit which itself generates an interrupt. An interrupt is generated when the NE flag is set during multi buffer communication if the EIE bit is set.

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. When transmitting data in smartcard mode, 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_CR3 register.

0: No Framing error is detected

1: Framing error or break character is detected

Note: 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: This error is associated with the character in the LPUART_RDR.

34.7.8 LPUART interrupt and status register [alternate] (LPUART_ISR)

Address offset: 0x1C

Reset value: 0x0000 00C0

The same register can be used in FIFO mode enabled (previous section) and FIFO mode disabled (this section).

FIFO mode disabled

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.REACKTEACKWUFRWUSBKFCMFBUSY
rrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.CTSCTSIFRes.TXETCRXNEIDLEORENEFEPE
rrrrrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 REACK : 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 low-power mode.

Note: If the LPUART does not support the wake-up from Stop feature, this bit is reserved and kept at reset value.

Bit 21 TEACK : 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 : Wake-up from low-power mode flag

This bit is set by hardware, when a wake-up event is detected. The event is defined by the WUS bitfield. 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.

If the LPUART does not support the wake-up from Stop feature, this bit is reserved and kept at reset value

Bit 19 RWU : Receiver wake-up from mute mode

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

When wake-up 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 wake-up from Stop feature, this bit is reserved and kept at reset value.

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: Break character transmitted

1: Break character requested by setting SBKRQ bit in LPUART_RQR register

Bit 17 CMF : Character match flag

This bit is set by hardware, when 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 ongoing 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:11 Reserved, 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 CTS input pin.

0: CTS line set

1: CTS line reset

Note: If the hardware flow control feature is not supported, this bit is reserved and kept at reset value.

Bit 9 CTSIF : CTS interrupt flag

This bit is set by hardware when the CTS 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 CTS status line

1: A change occurred on the CTS status line

Note: If the hardware flow control feature is not supported, this bit is reserved and kept at reset value.

Bit 8 Reserved, must be kept at reset value.

Bit 7 TXE : Transmit data register empty/TXFIFO not full

TXE is set by hardware when the content of the LPUART_TDR register has been transferred into the shift register. It is cleared by a write to the LPUART_TDR register.

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

0: Data register full

1: Data register 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 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 immediately set.

Bit 5 RXNE : Read data register not empty

RXNE bit is set by hardware when the content of the LPUART_RDR shift register has been transferred to the LPUART_RDR register. It is cleared by reading from the LPUART_RDR register. The RXNE flag can also be cleared by writing 1 to the RXFRQ in the LPUART_RQR register.

An interrupt is generated if RXNEIE = 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 LPUART_RDR register while RXNE = 1. It is cleared by a software, writing 1 to the ORECF, in the LPUART_ICR register.

An interrupt is generated if RXNEIE = 1 or EIE = 1 in the LPUART_CR1 register, or EIE = 1 in the LPUART_CR3 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 NE : 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 NECF 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 bit which itself generates an interrupt. An interrupt is generated when the NE flag is set during multi buffer communication if the EIE bit is set.

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.

When transmitting data in smartcard mode, 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_CR3 register.

0: No Framing error is detected

1: Framing error or break character 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 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

34.7.9 LPUART interrupt flag clear register (LPUART_ICR)

Address offset: 0x20

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WUCFRes.Res.CMCFRes.
ww
1514131211109876543210
Res.Res.Res.Res.Res.Res.CTSCFRes.Res.TCCFRes.IDLECFORECFNECFFECFPECF
wwwwwww

Bits 31:21 Reserved, must be kept at reset value.

Bit 20 WUCF : Wake-up from low-power 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 wake-up from Stop feature, this bit is reserved and kept at reset value. Refer to Section 33.4: USART implementation.

Bits 19:18 Reserved, must be kept at reset value.

Bit 17 CMCF : Character match clear flag

Writing 1 to this bit clears the CMF flag in the LPUART_ISR register.

Bits 16:10 Reserved, must be kept at reset value.

Bit 9 CTSCF : CTS clear flag

Writing 1 to this bit clears the CTSIF flag in the LPUART_ISR register.

34.7.10 LPUART receive data register (LPUART_RDR)

Address offset: 0x24

Reset value: 0x0000 0000

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:9 Reserved, must be kept at reset value.

Bits 8:0 RDR[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 341 ).

When receiving with the parity enabled, the value read in the MSB bit is the received parity bit.

34.7.11 LPUART transmit data register (LPUART_TDR)

Address offset: 0x28

Reset value: 0x0000 0000

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:9 Reserved, 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 341 ).

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.

34.7.12 LPUART prescaler register (LPUART_PRESC)

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

Address offset: 0x2C

Reset value: 0x0000 0000

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:4 Reserved, must be kept at reset value.

Bits 3:0 PRESCALER[3:0] : Clock prescaler

The LPUART 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.

If the prescaler is not supported, this bitfield is reserved and must be kept at reset value. Refer to Section 34.3: LPUART implementation on page 1073 .

34.7.13 LPUART register map

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

Table 204. LPUART register map and reset values

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x00LPUART_CR1
FIFO mode enabled
RXFFIETXFEIEFIFOENM1Res.Res.DEAT[4:0]DEDT[4:0]Res.CMIEMMEM0WAKEPCEPSPEIETXFNFIETCIERXFNEIEIDLEIETEREUESMUE
Reset value00000000000000000000000000000
0x00LPUART_CR1
FIFO mode disabled
Res.Res.FIFOENM1Res.Res.DEAT[4:0]DEDT[4:0]Res.CMIEMMEM0WAKEPCEPSPEIETXEIETCIERXNEIEIDLEIETEREUESMUE
Reset value000000000000000000000000000
0x04LPUART_CR2ADD[7:0]Res.Res.Res.Res.MSBFIRSTDATAINVTXINVRXINVSWAPRes.STOP[1:0]Res.Res.Res.Res.Res.Res.Res.Res.ADD7Res.Res.Res.Res.Res.
Reset value0000000000000000
0x08LPUART_CR3TXFTCFG[2:0]Res.RXFTIERes.RXFTCFG[2:0]Res.TXFTIEWUFIEWUS[1:0]Res.Res.Res.Res.DEPDEMDDREOVRDISRes.CTSIECTSERTSEDMATDMARRes.Res.HDSELRes.Res.EIE
Reset value0000000000000000000000
0x0CLPUART_BRRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.BRR[19:0]
Reset value00000000000000000000
0x10-0x14Reserved
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.TXFRQRXFRQMMRQSBKRQ
Reset value0000
0x1CLPUART_ISR
FIFO mode enabled
Res.Res.Res.Res.TXFTRXFTRes.RXFFTXFFREACKTEACKWUFRWUSBKFCMFBUSYRes.Res.Res.Res.CTSCTSIFRes.TXFNFTCRXFNEIDLEORENEFEPE
Reset value000100000000011000000
0x1CLPUART_ISR
FIFO mode disabled
Res.Res.Res.Res.Res.Res.Res.Res.Res.REACKTEACKWUFRWUSBKFCMFBUSYRes.Res.Res.Res.CTSCTSIFRes.TXETCRXNEIDLEORENEFEPE
Reset value00000000011000000
0x20LPUART_ICRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.WUCFRes.Res.CMCFRes.Res.Res.Res.Res.Res.CTSCFRes.Res.TCFRes.IDLECFORECFNECFFECFPECF
Reset value000000000
0x24LPUART_RDRRes.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 value000000000
0x28LPUART_TDRRes.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 value000000000

Table 204. LPUART register map and reset values (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x2CLPUART_
PRESC
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.Res.PRESCALER[3:0]
Reset value0000

Refer to Section 2.2: Memory organization for the register boundary addresses.