MCU Low Power Design (ii) practiceKey Words:
MCU low power consumption, stm8l low power consumption, energy saving practice, IAR development environment, ammeter measurement power consumption
Introduction:
Energy consumption is a major problem with battery-powered products, and once the power is exhausted the device will "strike". In the MCU low power Design (a) theory, we introduce the principle of energy saving, this paper uses multimeter and MCU circuit board, Real thing to test the power consumption value. Simple but absolutely real test data to see how far the official claims of low power and measured results are, let's go!
Description
Blog writing tools for image editing support is not enough, like Ben Boven readers can download the PDF version of the blog post from the following connection, it will be a better typesetting document.
A. Build a test environment1. Hardware platform:
Choose "Changsha Rui mi Communication Technology Co., Ltd. (www.rimelink.com)" Wireless communication module iwl881a (left), consider only the test MCU energy consumption, specifically the radio frequency module removal (right), MCU for St company ultra-low power consumption stm8l151c8t6.
2. Software platform:
The development platform chooses the IAR integrated development environment, its specific model is as the right figure:
3. Test tools:
Ultra-high-precision measurement of low power consumption, need battery simulator, that thing is RMB more than 200,000 A; foreigners (such as the father of Contiki Adam Dunkels) often connect 100 ohm resistor, with an oscilloscope to calculate the integration, more complicated; We use the simplest method, series ammeter, do not underestimate it, It is possible to measure the accuracy of the UA. The test environment is built as shown
two. Power consumption test in low power mode
Test MCU low Power comparison the scientific approach is to use the addition principle, that is, first test the lowest operating power consumption, and then add the peripheral or I/O pins, step by step test the power consumption of the components.
To better test the power consumption of the STM8L151C8, we wrote a C language test software that included 5 of the MCU's low-power operating modes. When testing the corresponding run mode, you only need to modify the macro definition: #define Mcu_mode mode_xxxxxx.
Readers can download the test code directly from the following link:
http://download.csdn.net/detail/jiangjunjie_2005/8959145
The following link downloads the sister chapter of this blog post: "MCU low power Design (i) theory"
http://download.csdn.net/detail/jiangjunjie_2005/8957767
1. Halt power consumption
Set the test code macro definition to:
#define Mcu_mode Mode_halt
Compiled and burned into the MCU, and the ammeter adjusts to a 2mA range. As you can see, the power consumption is 0.4uA in halt mode.
St Company Product Brochure: Halt (NA)
It seems that the people of faith (basically Christians in Western Europe) are more likely to tell the truth!
2. Active-halt Power consumption
Set the test code macro definition to: #defineMCU_MODE mode_active_halt, compile and burn into the MCU, the ammeter is still 2mA range. As you can see, the power consumption is 1.0uA and 2.2uA in Active-halt mode, why are there 2 values?
If you read the first post in this series, "MCU Low power Design (a) theory", then you know that the lower power consumption (1.0uA) is the halt state, while the higher Power consumption (2.2uA) is the wake state. Why is the same stop, Active-halt (1.0uA) is higher than Halt (0.4uA) power consumption? The answer is that the former has a 38kHz internal RC Crystal in operation, it gives RTC clock source, it also needs power Oh!
St Company Product brochure: Active-halt with full RTC (1.4 UA)
If we simply take the 1.0uA and 2.2uA to an average, it would be 1.6uA, and the official data would be close. Of course, to more accurate measurement, need to take the oscilloscope record wake-up time duty ratio, this work for more rigorous follow-up to complete it (remember to send readers blog, technology to serve the nation, need to practice!) )。
3. Lowpowerwait Power consumption
Set the test code macro definition to:
#define Mcu_mode
Mode_low_power_wait,
You can see that the power consumption is 2.7uA.
St Company Product brochure: Low power Wait (3 UA)
That 0.3uA can calculate the test error no? Welcome to the discussion.
4. Lowpowerrun Power consumption
Set the macro definition to:
#define Mcu_mode
Mode_low_power_run
The power consumption in this mode is: 4.6uA.
St Company Product brochure: Low power Run (5.9 uA).
Measured power consumption is 1.3uA lower than the official claimed power consumption.
Let's take a look at how the MCU works in this mode.
① Enter the code sequence for "low power Run" mode:
L jump to ram;
L Switch the system clock to LSI or LSE;
L Turn off the high-speed crystal, ADC and unused peripherals;
• Block all interrupts;
L Turn off Flash and EEPROM; (add software delay to ensure successful shutdown)
L Configure a low-power voltage regulator.
② exit the code sequence for "low power Run" mode:
L Open the main voltage regulator;
L open Flash and EEPROM;
l Enable all interrupts;
L Open the peripherals you need to use and jump to flash and eeprom if necessary.
It is particularly important to note that, in Lowpower run mode, the MCU is executed from the RAM (not ROM) fetch instruction because the code snippet needs to be positioned in RAM. In the IAR environment, the code snippet is positioned in RAM, and the keyword "__ramfunc" needs to be added before the function. The instance function is declared as follows:
__ramfunc void Lpr_ram (void)
5. Wait Power
Read the first post, "MCU Low power Design (i) theory" readers will learn that the wait mode is only the CPU suspended operation, so that the crystal can be HSI (internal high speed) or LSI (internal low speed). Let's test the power consumption in his mode, set the mode: #define Mcu_mode mode_wait, set the clock: #define IS_ENABLE_LSI 0. The measured power consumption is: 687uA, shown on the right.
Re-test the power consumption in LIS mode, set the mode: #define Mcu_mode mode_wait, set the clock: #define IS_ENABLE_LSI 1, the measured power consumption is: 82uA, shown on the left.
St Company Product Brochure: Wait, Low power Run (5.9 UA)
Why there is such a big gap, the answer is afraid of St company's technical staff to answer!
6. Run Power
When the MCU is running at HSI (16MHZ) high speed, its power dissipation is as shown on the left: 5.3mA (2 and 3 digits after the decimal point are measured).
St Company Product Brochure: consumption:200 Ua/mhz +.
According to the above formula calculation, the theoretical power consumption should be 3.5mA, and the measured value of 5.3mA there is a large difference, I would like St company's technical staff to answer.
When the MCU is running at LSI (38KHZ) Low speed, its power dissipation is as shown in the right: 95.6uA. According to the official declared static energy consumption 330uA, the difference is not small.
Together, we summarize the power dissipation and enabling components in the above operating modes.
program in RAM wait
program runs in RAM
St claims |
Measured power consumption |
Low power consumption instruction |
Crystal oscillator |
Description |
Enabling parts |
400nA |
0.4uA |
Halt |
Independent |
Close the Internal reference voltage |
/ |
1.4ua |
< Span style= "font-size:18px" >1.1ua |
Activehalt |
unrelated |
wake-up from RTC |
LSI+RTC |
3ua |
< Span style= "font-size:18px" >2.7ua |
lowpowerwait |
lsi=38khz | TD Nowrap>
< Span style= "font-size:18px" >lsi+cpu+sram |
5.9ua |
< Span style= "font-size:18px" >4.6ua |
Lowpowerrun |
lsi=38khz | TD Nowrap>
< Span style= "font-size:18px" >lsi+cpu+sram |
5.9ua |
< Span style= "font-size:18px" >82ua |
wfi/wfe |
lsi=38khz |
low-speed crystal wait |
lsi+cpu+sram+flash+eeprom |
|
687ua |
wfi/wfe |
hsi=16mhz |
high-speed crystal wait |
hsi+cpu+sram+flash+eeprom |
3.5ma |
< Span style= "font-size:18px" >5.3ma |
16MHz run |
hsi=16mhz |
while (1) Run continuously |
hsi+cpu+sram+flash+eeprom |
330uA |
95.6uA |
38kHz operation |
Lsi=38khz |
while (1) uninterrupted operation |
Lsi+cpu+sram+flash+eeprom |
three. I/O pin and peripheral power consumption test
The peripheral requires HSI (high speed external crystal) or LSI (Low speed crystal) to provide a clock source, so the test peripherals generally work in the wait mode: When the CPU stops running, the measured power value of the peripheral turned off is subtracted from the measured power consumption at the time of shutdown, and the operating power consumption value of the peripheral is available.
The number of peripherals is more, we test some common peripheral power consumption is as follows:
Power |
Peripherals |
Description |
170uA |
Uart |
Idle Energy |
60uA |
Tp. |
Idle Energy |
30uA |
TIM1 |
Timer 1 Continuous operation |
30uA |
IWDG |
Independent watchdog continuous operation |
The I/O pin is an analog device, often with a higher power consumption, such as a Pin5 (PA4) in the test circuit above, which is connected to the LED. After enabling and prohibiting the LED pin, the measured current is 320uA.
Generally, I/O pins need to be connected to a certain logic level. For all I/O pins that are not connected to the deterministic logic signal need to be configured, otherwise the external noise will cause increased power consumption, such as the Schmitt trigger inside the PIN detects the rollover of the noise and consumes energy: the input PIN is configured to pull up and the output PIN is configured with a low (or high) logic level.
Related articles:
"MCU Low-power design (i) theory"
"MCU Low-power design (iii) products"
Author Profile:
Shu Jun, male, master, is currently the CEO of Changsha Communications Technology Co., Ltd.
Engaged in communication research and embedded development 10, the main focus on micro-power wireless network.
Proficient in Lora Wireless spread spectrum communication, wireless star/tree-type/mesh network design;
Proficient in contiki,linux,uc/os-ii,osal and other operating systems;
Familiar with arm,dsp,stm8,pic,pc104 and other processors;
Good at AD,RF and other integrated IC development.
Web:www.rimelink.com
Email: [email protected]
QQ Group: 35212129
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
MCU low Power Design (ii) practice