AN4635
Application note
Minimization of power consumption using LPUART
in microcontrollers of the STM32L0 series
Introduction
Microcontrollers of the STM32L0 series feature an alternative UART interface, designed to
allow the MCU to operate with minimum power requirements.
This document aims to explain how to fully exploit the advantages of the Low Power UART
(LPUART), thus extending product battery life for the above mentioned products.
It shows in practical examples the extremely low power consumption of the device waiting
for a communication.
The following documents (available from
www.st.com)
are to be considered as reference:
•
Application note AN4445: “STM32L0xx ultra-low power features overview”
•
Reference manual RM0376: “Ultra-low-power STM32L0x2 advanced ARM
®
-based 32-bit
MCUs”.
April 2015
DocID027290 Rev 1
1/34
www.st.com
1
Contents
AN4635
Contents
1
2
3
Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Summary of features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Operation modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.1
3.2
3.3
3.4
Polling mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
IT mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
DMA mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Combined mode examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4.1
3.4.2
Interrupt with polling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Combining DMA with direct access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4
Other considerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1
4.2
4.3
GPIO configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Clock configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.2.1
4.3.1
4.3.2
Clock prescalers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Use of Stop and Sleep modes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Run time configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Power configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
5
Reliability and communication quality . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1
5.2
Noise and frequency shift . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Dropped bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
6
Power consumption comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
6.1
6.2
6.3
6.4
6.5
6.6
6.7
6.8
Stop vs. Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Short periods of Sleep mode and Low power run . . . . . . . . . . . . . . . . . . 16
Interrupt operation overhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Going to Stop between received bytes . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Different oscillator clock speeds . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Changing AHB divider ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Different peripheral clock settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
ULP bit setting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
DocID027290 Rev 1
2/34
AN4635
Contents
6.9
6.10
6.11
6.12
Higher communication speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Wakeup from Stop mode on HSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Voltage regulator settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
GPIO Pull-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
7
Example project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
7.1
7.2
7.3
HW setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Configuring the example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
Example operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
8
9
Conclusion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
DocID027290 Rev 1
3/34
3
List of tables
AN4635
List of tables
Table 1.
Table 2.
Table 3.
Table 4.
Table 5.
Table 6.
Table 7.
Table 8.
Table 9.
Table 10.
Table 11.
Table 12.
Table 13.
Table 14.
Table 15.
Table 16.
List of acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Comparison of features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Clock options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Configurations - Stop vs. Sleep mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Configurations - Sleep mode vs. LPRUN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Configurations - Interrupt operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Configurations - Stop during data reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Configurations - Core clock speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Configurations - AHB divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
Configurations - Clock divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
Configurations - ULP bit effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Configurations - Higher communication speed . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
Configurations - HSI vs. MSI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Configurations - Voltage regulator settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
Configurations - GPIO pull-up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4/34
DocID027290 Rev 1
AN4635
List of figures
List of figures
Figure 1.
Figure 2.
Figure 3.
Figure 4.
Figure 5.
Figure 6.
Figure 7.
Figure 8.
Figure 9.
Figure 10.
Figure 11.
Figure 12.
Figure 13.
Test loop description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Stop vs. Sleep mode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Sleep mode vs. LPRUN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Interrupt operation overhead . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Using the Stop during data reception . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
Core clock speed comparison . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
Lowering oscillator speed compared to AHB divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
Three different settings of peripheral clock divider . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
ULP bit effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Operating at 57600 baud . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
HSI vs. MSI at 4 MHz . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Comparison between voltage regulator settings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
GPIO internal pull-up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
DocID027290 Rev 1
5/34
5