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 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.
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.
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.