Hi, I am using the below function to enter low power mode in STM32L152, but yet the current consumption of MCU is about 4 mA. is there other configurations?
RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR,ENABLE); PWR_EnterLowPowerRunMode(ENABLE);
I achieved the low power modes of MCU to about 3uA. The following commands set the MCU to low power sleep mode:
RCC_Configuration(); PWR_VoltageScalingConfig(PWR_VoltageScaling_Range1); /* Wait Until the Voltage Regulator is ready */ while (PWR_GetFlagStatus(PWR_FLAG_VOS) != RESET) ; /* Init I/O ports */ Init_GPIOs(); GPIO_LowPower_Config(); Config_RCC(&SavRCC); ExtInt_configuration(); SysTick->CTRL = 0; SetHSICLKToMSI(RCC_MSIRange_0,DIV2,NoRTC); SystemCoreClockUpdate(); enableInterrupts(); //TIM4_configuration(); PWR_EnterSleepMode(PWR_Regulator_LowPower,PWR_SLEEPEntry_WFI);
My problem yet is that after switching between modes(RUN,LPR,LPS,..)the MCU does not enter to low power mode!
The definitive guide to Cortex M0 end of chapter 17, suggests that on some processors if you have a debugger hooked up extra power will be required to provide the debugger the power it needs. it also says that just unplugging the debugger will not lower the current in some processors. What is required is to power the part down and power back up without the debugger connected on some processors.
To me, this smells like a GPIO pin that is not clamped and energizes its transistors. Did you sure you disabled your GPIO block power supply?
No I mean 1.5 mA less than previous condition. I have not yet achieved less than 4 mA. Did you use the code generated by Cube32 without any changing to have a consumption in range of micro amperes?
I added a step with 100 seconds, disabled all peripherals and clock adjusted to 32kHz after downloading the project output to flash the MCU power consumption was about 8mA
when I set the MCU frequency on 32Khz when LED is off the consumption decreases about 1.5mA.
From 8mA to 1.5mA, I believe you have already found something important.
Dear John, Indeed I did what you said I used an LED in series with 1K using GPIO_ToggleBits command in a while loop to see its frequency which gives me a view about operation of the MCU and its frequency. when I set the MCU frequency on 32Khz the led toggled in about 2Khz which verifies 32Khz clock. The current consumption is about 5mA. when LED is off the consumption decreases about 1.5mA. when clock is set to 16Mhz the led toggled about 1Mhz and current consumption is about 11mA when led is on and 10mA when LED is off.
upto this point there is a problem not solved for me. why MCU consumes this much current in 32kHz. I configured all pins as analog input too but no change in current.
Have you ever configured the MCU running on normal mode and measured the current consumption? What is that value?
1. MCU running on normal mode, a LED is on. 2. MCU running on normal mode, a LED is off. 3. MCU sleeping, a LED is on. 4. MCU sleeping, a LED is off.
In order to go the first step in having a simple program in low power sleep for STM32L152VD I used STM32CubeMX software and configured power mode from 4th tab. I added a step with 100 seconds, disabled all peripherals and clock adjusted to 32kHz and the result was 4uA but after downloading the project output to flash the MCU power consumption was about 8mA (About 2000 times more than estimated). I am sure this is the power consumption of MCU not other element on the board. Where is the problem??
I used a code to change HSI to MSI but there is some challenges when switching from MSI to HSI inside a program. Does cube32 tool make it easy to switch from MSI to HSI and back again to MSI any time in the program? Also there is a question for me why library files in this tool different from standard libraries presented for STM32L1xx from ST, so that after using this wizard I cannot add the files to my project written by those libraries!
Since you are using STM32 device, you should use the cube32 tool to set up your power management. Their tool has a 4th tab dedicated to power management, and even estimates current draw.
As noted, the low power current should not be measured with any JTAG interface connected.
Next thing is that it's important to select a proper voltage regulator. A normal voltage regulator can have quite high idle current because it's designed to have good load regulation, i.e. very little output voltage variation if you draw 1mA or if you draw 1000mA. A voltage regulator for low-energy battery operation need not have as good load regulation - but must instead have a very, very low idle current so you don't get the majority of the power consumption in the regulator itself.
What current are you measuring where?
On the L1-DISCO board you should be most interested in the JP1 jumper, at that point you've partitioned the chip from the ST-LINK and other circuitry. Measuring the current drawn on the 5V rail on the backside of the regulator is probably not going to provide useful numbers.
You should probably more selective in your GPIO configuration so as not to break the debugger connection. Although having the debugger attached is going to skew the results.
I don't work with your processor.
But if the current is the same when you change the amount of instructions/second your processor runs, then your issue isn't dynamic consumption but static consumption. So you have to investigate what sources you have of static consumption. It's enough with a single processor pin that fights something to consume 4mA. Next thing is that you normally don't want to busy-loop a processor when you want lowest power. You want to sleep it and only wake up for interrupts. Then directly send it back to sleep again. Remember that a while loop does nothing useful, but still forces the processor to tick instructions at the maximum speed the clock allows - that's wasted energy when the program might just need to wake once/second or if a specific GPIO pin changes state.
Thanks for your points. Indeed to measure the current of MCU I have not soldered any other parts on my board. As you said I could not use Discovery board because its consumption is about 60mA with all parts on it. it seems any change in MSI frequency does not affect the power consumption of my board. Any Idea t go step by step to make power consumption low?
The clock settings is as follows:
*============================================================================= * System Clock Configuration *============================================================================= * System Clock source | MSI(Range0) *----------------------------------------------------------------------------- * SYSCLK | 65000 Hz *----------------------------------------------------------------------------- * HCLK | 65000 Hz *----------------------------------------------------------------------------- * AHB Prescaler | 1 *----------------------------------------------------------------------------- * APB1 Prescaler | 1 *----------------------------------------------------------------------------- * APB2 Prescaler | 1 *----------------------------------------------------------------------------- * HSE Frequency | 8000000 Hz *----------------------------------------------------------------------------- * PLL DIV | Not Used *----------------------------------------------------------------------------- * PLL MUL | Not Used *----------------------------------------------------------------------------- * VDD | 3.3 V *----------------------------------------------------------------------------- * Vcore | 1.2 V (Range 3) *----------------------------------------------------------------------------- * Flash Latency | 0 WS *----------------------------------------------------------------------------- * Require 48MHz for USB clock | Disabled *----------------------------------------------------------------------------- *=============================================================================
and in main.c :
int main(void) { SystemInit(); SystemCoreClockUpdate(); /* Configure all GPIO as analog to reduce current consumption on non used IOs */ /* Enable GPIOs clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOH | RCC_AHBPeriph_GPIOF | RCC_AHBPeriph_GPIOG, ENABLE); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_40MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure); GPIO_Init(GPIOH, &GPIO_InitStructure); GPIO_Init(GPIOF, &GPIO_InitStructure); GPIO_Init(GPIOG, &GPIO_InitStructure); GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); /* Disable GPIOs clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOE | RCC_AHBPeriph_GPIOH | RCC_AHBPeriph_GPIOF | RCC_AHBPeriph_GPIOG, DISABLE); PWR_EnterLowPowerRunMode(ENABLE); /* Wait until the system enters RUN LP and the Regulator is in LP mode */ while(PWR_GetFlagStatus(PWR_FLAG_REGLP) == RESET) { } while(1) { }
View all questions in Keil forum