STM32 LPUART

What is special in LPUART i.e. Low Power UART ?

The LPUART is a peripheral that is developed targeting the low power applications of a generic UART module. The LPUART provides full UART communications while being clocked by an  oscillator of 32.768 kHz! Now some of you might be thinking, what difference does it make by just changing the frequency of the clock that drives the peripheral?

Well, if you’re from Electrical/Electronics background, either you have or you’ll soon study the fact that operating frequency of a circuit is directly proportional to its’ power consumption, i.e. lower the frequency, lower the power consumption! Just for a little explanation, we know that P=VI, and I = q/t, and also f = 1/t, by looking at these relations, one can roughly figure that P ∝ f. People interested for in-depth derivation may refer the textbook: SungMo (Steve) Kang on CMOS Digital Integrated Circuits

In fact , Industry is dealing with challenges of frequency in CPU world by various means. You may like to read Parallel Computing .

What  Baudrate options are available with STM32 LPUART ?

Now, the experienced folks might be wondering that is it possible to achieve a baud rate compatible with other devices at such a low frequency clock? The answer is Yes! The LPUART peripheral is capable of providing a max baud of 9600 while being clocked at 32.768 kHz! Although faster baud rates (up to 26Mbaud in case of STM32) are also possible with different sources of clock. The typical clocking options for the LPUART in STM32 MCUs are shown in the figure below:

What about clocking and hardware control signals in STM32 LPUART ?

The dual clocking scheme enables registers to be accessed using the Peripheral clock and the rest of the peripheral can be clocked from a different source, i.e. independent of Pclk. Applications can take the advantage of such an inexpensive connection between devices using LPUART. In addition, the LPUART is also functional low power modes! One can imagine the amount of applications this feature can serve. Not only this, but the LPUART also supports full hardware flow control through RS-232 & RS-485. The LPUART supports the standard programmable data formats as supported by any normal UART as shown below:

Start Bit: Marks the start of a data packet by changing the line status from IDLE (HIGH).

Data Bits: The bits of the data packet being transferred, programmable data length options are 7, 8 & 9 bits.

Parity Bit: Added redundant bit for Error Detection, programmable to None, Odd or Even Parity. The parity bit helps to know if a bit has changed during transmission. Bits may be flipped due to noise (electromagnetic radiation, mismatched baud rates, or long-distance data transfers).

   Once the data is received the peripheral reads the data frame, it counts the number of bits with a value of 1 and checks if the total is an even or odd number. If the parity bit is a 0 (even parity), the number of 1s (high bits) in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1s (high bits) in the data frame should total to an odd number.

When the parity bit matches the data, the peripheral knows that the data is error-free. But if the parity bit is a 0, and the total is odd; or the parity bit is a 1, and the total is even, the peripheral knows that the data packet has an error.

Stop Bit: Marks the end of a frame by changing the state of the line to IDLE for 1 or 2 sampling cycles.

LPUART Modes

The LPUART supports two modes when it comes to duplexity, namely, Full-Duplex & Half-Duplex mode as shown in the figure. In the half duplex mode, Tx & Rx lines are internally connected & the Tx Pin, i.e. a single wire is capable of bi-directional flow of data, one direction at a time. The Tx line is released when no data is being transmitted, i.e. it acts as a standard I/O in idle state or while receiving any data, therefore for this functionality the Tx Pin must be configured in Alternate Function Open-Drain mode, with an external pull-up resistor as shown in the figure:

MCU Wakeup from Stop Mode

The LPUART is also capable of waking up the MCU from stop mode but only if the clock source selected is LSE (32.768kHz) or HSI (16MHz). The sources causing a wakeup can be:

  1. Standard Reception Interrupt (Receive buffer Not Empty)

  2. Wakeup events triggered by:

    1. Start Bit

    2. Address Match

    3. Any received data

That means the device you connect your MCU with can be like a friend that keeps on waking you up in intervals while you sleep through a lecture. The Activity of LPUART during different low-power modes in an STM32 MCU can be seen in the following table:

Conclusion

Along with so many features, there are a few features the LPUART don’t have as compared to a normal UART peripheral. Although the LPUART in an STM32 doesn’t support a few features like LIN etc. but other companies such as NXP provide these features in their LPUART and also with the ever-growing technology, adding features isn’t a tough job for semiconductor giants.

The comparison of such features for a typical STM32 device can be observed in the table below (‘✔’ means the feature exists ; ‘X ‘means the feature is dropped):

Additional Reference

The following are a few good application notes for The LPUART Peripheral:

  1. NxP AN5402
  2. ST AN4635

 

Authors :

Aditi Bhatnagar

Aditi is a student of Electronics and Communications Engineering, currently in the 4 th year of B.Tech in Institute of Technology, Nirma University, Ahmedabad. She is also pursuing Minor Specialization in Computer Engineering at Nirma University. Her fields of interest include Embedded Systems, Internet of Things, Embedded Linux, Networking and Wireless Sensor Networks. She started exploring the field of Embedded Systems in her 2 nd year in which she developed keen interest in developing embedded applications. She has done various minor and major projects in college. She has successfully published a research paper on one of her projects based on Wireless Sensor Networks.

Pranjal Shrivastava

Pranjal is an Electronics & Communications Engineering Student, completed 3rd Year at Institute of Technology, Nirma University, Ahmedabad .I n the initial years, he was in the Robocon Team of college where he got interested into Robotics , mainly concerning Robotic Drives , Motion & Path planning. Along with that currently his fields of interests are Internet of Things,  Embedded Systems & Re-configurable Hardware. He has done few projects as  Mini Projects in college & currently working to publish a paper on one of those projects. He has successfully published a research paper based on his project

Nirma University Admission Criteria

Thanks for reading till end. If you liked it, Please share in your network.

You may  find interesting topics at HowTo

Also subscribe  Embedkari for other interesting topics. .

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.