STM32 low power experiment summary

Publisher:RadiantSerenityLatest update time:2019-12-20 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. First of all, let me answer a question: Can STM32 achieve low power consumption? 
The answer is yes, and there is data to support this. When I tested the STM32101CB, FLASH: 128K, RAM: 16K and RTC working, the power consumption was 16uA, which is quite good. 


2. What should I pay attention to when it comes to STM32 low power consumption? 
When I first tested that the STM32 power consumption was 16uA, I was very happy and thought it could really be used for my application. My application is to make the MCU wake up regularly to work, work for a while and then go to sleep. The working time may be only a few dozen milliseconds. But later I found some problems (working in STOP mode): 


1) Clock problem: After the STM32 is awakened, the clock automatically switches to the internal HIS RC oscillator. As we all know, the accuracy of the RC oscillator is not high. Moreover, the clock settings before going to bed are all restored to the reset state, only the clock is reset, and the others are not. This will also bring a problem. Maybe you use the internal clock before going to bed, but after going to bed, the clock changes, and the problem is UART and timer. Maybe you don't want to use PLL, that is, 8M, so that the clock HIS after waking up is also 8M. In this way, although there is no difference in the clock, the clock is unstable. The UART baud rate must not be too high, otherwise there will be communication problems. 


2) Wake-up time: This is also a very big problem. The wake-up time given in the datasheet is 7us, which may be true, but after waking up, you can't do your work immediately. Why? Initialize IO. You may ask, can't I not initialize it? The answer should be no. Because if you want to use low power consumption, the IO ports should be set to analog input before going to bed, so that the 14uA on the datasheet can be achieved, but this also brings a problem, that is, initialize IO. You must initialize IO when you wake up. If you also want to switch the clock to an external clock, it will take even longer, close to 200ms, because the STM32 will wait for the external clock to stabilize before it can work, and then reinitialize all IO, which is very time-consuming. Maybe I only need to wake up for 10ms, but it takes 100ms to complete these tasks. 


3) RTC wake-up: RTC is also a problem, why? Everyone needs to pay attention that RTC can only use alarm to wake up the MCU, and the second interrupt cannot wake up. And the alarm interrupt must be set continuously, and it will only take effect once set. After the interrupt is over, you need to set the time of the next interrupt. And there is another problem. The alarm interrupt must wait until the second interrupt arrives before it can be set, that is, it is set when the second register is updated once. This brings a problem, waiting for the second interrupt. If you want to be awakened by the alarm before going to bed, you must reset the alarm interrupt, and when setting the alarm interrupt, you need to wait until the second interrupt to set the new value. The waiting time is uncertain. It may be hundreds of milliseconds. So it takes hundreds of milliseconds to wait for the second interrupt flag to set the alarm interrupt. Maybe my MCU only needs to execute 10ms before it needs to go to sleep. It still takes hundreds of milliseconds to waste. 


Summary: I have explained above the problems I found during use. I think the low power consumption of STM32 is too fake. Although the performance is good when asleep, the settings for waking up and entering sleep are too troublesome and time-consuming. This is a disadvantage. I think MSP430 is probably the best. Even AVR is better than it and is not so troublesome.


After getting the STM32L sample, I have been struggling with the low power consumption test. Because the configuration is different from the STM32F series, it led to a tragedy. After constant consultation with ST, I finally got the final result. 
After testing, the power consumption is 500nA in STOP mode, and the performance is still good. The code is as follows: 

/** 
  *  @brief   Main program. 
  * @param None 
  * @retval None 
  */ 
int main(void) 

  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32l1xx_md.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32l1xx.c file 
     */ 
     /* Configure all unused GPIO port pins in Analog Input mode (floating input
     trigger OFF), this will reduce the power consumption and increase the device
     immunity against EMI/EMC *****************************************************/
    GPIO_InitTypeDef GPIO_InitStructure; 
    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC 

                        | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOH, ENABLE);

    /* config all IO to Analog Input to reduce parasite power consumption */

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; 

    GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_400KHz;

    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;

    GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

    _InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;

    GPIO_Init(GPIOC, &GPIO_InitStructure); 

    GPIO_Init(GPIOD, &GPIO_InitStructure); 

    GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOH 

    , &GPIO_InitStructure); 

    GPIO_Init(GPIOA, &GPIO_InitStructure); 

    GPIO_Init(GPIOB, &GPIO_InitStructure);  

    /* Enable PB7 as external PVD input so as to set it as AIN_IN */
    Set_PVD_To_Config_PB7(); 

    RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA  
                          | RCC_AHBPeriph_GPIOB 
                          | RCC_AHBPeriph_GPIOC 
                          | RCC_AHBPeriph_GPIOD 
                          | RCC_AHBPeriph_GPIOE 
                          | RCC_AHBPeriph_GPIOH, DISABLE);
     
    PWR_UltraLowPowerCmd(ENABLE); 
    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
    while(1); 

/** 
  * @brief Enable PB7 as external PVD input so as to set it as AIN_IN 
  * @param None 
  * @retval None 
  */ 
void Set_PVD_To_Config_PB7(void) 

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 

  /* Configure the PVD Level to 3 (2.5V) */
  PWR_PVDLevelConfig(PWR_PVDLevel_7); 

  /* Enable the PVD Output */ 
  PWR_PVDCmd(ENABLE);   
}

Keywords:STM32 Reference address:STM32 low power experiment summary

Previous article:STM32L151C8 periodically wakes up from standby mode (RTC Wakeup Timer)
Next article:stm8L15x EEPORM study notes

Recommended ReadingLatest update time:2024-11-22 20:20

The difference and understanding of STM32's "external interrupts" and "events"
Anyone who has worked on ST MCU application development often encounters the three concepts or terms of events, interrupts, and events. These three concepts are related to each other, which can sometimes be confusing.  Let's first use an analogy from life to give a basic and rough understanding of the above three conc
[Microcontroller]
How to port uCGUI to STM32, see here!
Part 1: Before UCGUI Porting Before porting, you must first understand the file structure of the UCGUI 3.98 source code downloaded from the Internet. There are three folders in the UCGUI 3.98 source code: 1) The "tool folder" is used to use some uCgui host programs, basically fonts and template viewing. 2) Und
[Microcontroller]
Design of LF RFID identification system based on STM32
Radio Frequency Identification (RFID) is an automatic identification technology that has matured since the 1980s. RFID uses radio frequency to conduct non-contact two-way communication to achieve identification purposes and exchange data. It mainly achieves contactless information transmission through spatial coupling
[Microcontroller]
Design of LF RFID identification system based on STM32
stm32 GPIO speed mode understanding
1. Input/output mode (refer to stm32 manual) 2. The difference between several speeds in GPIO output mode: (1). GPIO pin speed: GPIO_Speed_2MHz (10MHz, 50MHz);     Also known as the response speed of the output drive circuit: (The chip has multiple output drive circuits with different response speeds arranged in t
[Microcontroller]
STM32_TEST.axf: Error: L6218E: Undefi
        The error message of this problem has clearly told you where the error is, Undefined symbol SystemInit, which means: SystemInit symbol is not defined. The small brackets that follow tell you that it is mentioned in the startup_stm32f10x_md.o file. This .o file does not exist in the project. It is generated acco
[Microcontroller]
STM32 key detection (EXTI and Polling)
In XTI Mode, as long as you don't miss the following two lines, there will be basically no problem. RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); /* Multiplexed clock enable*/ GPIO_EXTILineConfig(GPIO_PortSourceGPIOB,GPIO_PinSource1); /* Select GPIO pin as external interrupt line */ #include #include
[Microcontroller]
STM32 serial port idle interrupt problem
1. The idle interrupt is triggered when a byte of high level (idle) appears after receiving data. It does not mean that the idle interrupt will continue. To be precise, it should be a byte after the rising edge (stop bit). If it is always at a low level, the idle interrupt will not be triggered (it will trigger a brea
[Microcontroller]
STM32 MCU GPIO register
Each GPIO port has two 32-bit configuration registers (GPIOx_CRL, GPIOx_CRH) to control the high and low eight bits of each port respectively. If the IO port is 0-7, write the CRL register, if the IO port is 8-15, write the CRH register, two 32-bit data registers (GPIOx_IDR, GPIOx_ODR), one is read-only as input data r
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号