# How to debug current consumption with STM32 Nucleo board?

I'm trying to configure an STM32L011-Nucleo developement board to consume about 600 uA of current or so. It uses an STM32L011K4.

The datasheet states that this should be possible if I drive the MCU at 8 MHz and keep it in sleep mode for most of the time.

So I expect that MCU should consume about 1.3 mA or so in run mode. My exact case isn't listed - there are examples for 16 MHz HSI and 8 MHz HSE. I think that 1.3 mA is a good estimation.

In sleep mode:

So it is the same story: looking at 16 MHz HSE and 8 MHz HSE I could expect less than than 500 uA of consumption with 8 MHz HSE in sleep.

To test the current I put 100 Ohm through-hole resistor on the power jumper like this:

After all I have the following picture:

As you can see I have 1.7 mA in sleep and 2.2 mA in run modes. Which is WAY more than I expected.

I've already set all unused GPIO's to GPIO_Analog mode as I expect that this will minimize leakage current.

I've checked the schematic to verify that VDD is only feeding the MCU (looks like this is true).

I tried much lower frequencies and I was able to drop current consumption to 400 uA at 625 kHz which is also not match to datasheet...

Well, I have to state that I'm confused. AVR controllers (ATmega48PA) behaved as expected in one of my previous device.

Is there anything I am missing?

My clock configuration:

UPDATE

After I changed the PLL setting to None I reached less consumption: 1.1 mA for sleep and 2 mA for run mode:

• How did you probe the shunt? Maybe your ground is shifted by some additional currents? – jusaca Mar 15 at 9:33
• @MarcusMüller I wouldn't call 50Ohms by word typical but in my case the probe marked as 10 MOhms for 10:1 option (which is my case). My scope does not provide any optin to put the input into 50 Ohms mode so I think that it is really in high impedance mode. At least I hope so :))) – Roman Matveev Mar 15 at 9:35
• What I would like to see is the full schematic, containing everything that is connected to the uC and the VO and +3V3 nets. – Bimpelrekkie Mar 15 at 11:08
• How many of peripherals are enabled when you enter sleep mode? Are all unnecessary clocks disabled? I don't know the STM32, but when current consumption is not as expected, it's often some MCU/CPU setting that have been missed. If you current measuring setup works with the AVR MCU there is no reason it shouldn't work with the STM32. I would look for the solution in the CPU configuration. – Peter Karlsen Mar 15 at 11:12
• Did you notice that all datasheet numbers are listed for Vcore=1.5V and 1.8V, while you are feeding the MCU with 3.3V? – Ale..chenski Mar 15 at 14:43

You are measuring the voltage drop across the resistor with a single ended probe, thus grounding (earthing) one side.

Assuming that your scope is properly grounded, if you are using a supply that is not perfectly floating, you are probably measuring the current consumption of the board, plus the leakage in the supply. Many "isolated" supplies still use/require a resistor between the output negative voltage and the earth contact of the input.

Try putting the ground clip on the VDD side, and the probe tip on the MCU side. In this way, you still get leakage, but not into the resistor.

• This is a good one. He can use two channels and subtract them by scope's function... Or check the difference with a DMM, in a known steady regime, to check the sanity of scope data. – Ale..chenski Mar 25 at 4:55
• I tried to power the board with a powerbank. So this is for sure made my setup isolated and the probe - real differential. Same result :( – Roman Matveev Mar 25 at 8:35
• @RomanMatveev are you completely sure that your setup is isolated? perhaps your board has an usb connection to some grounded/leaking device? If you used a true differential probe though, the problem is somewhere else. – Vladimir Cravero Mar 25 at 9:27
• The board was connected to powerbank and scope. Nothing else. – Roman Matveev Mar 25 at 9:30

I suspect the unexpected current is being used by peripheral clocks.

The code generated by STM32CubeMX enables a bunch of clocks during initialization and leaves them running. Even if a clock is necessary to configure a peripheral, that clock can often be disabled afterwards (assuming you don't need that peripheral, of course!)

Go through your initialization code, noting which clocks get enabled. I'm using another family of STM32L's, not your STM32L0, but the commands should be similar. Look for something like LL_AHB1_GRP1_EnableClock(), or perhaps RCC_APB1PeriphClockCmd(), etc.

It's probably worth doing a text search for AHB and APB, to make sure you don't miss any. If you exclude the STM libraries from your search, the results shouldn't be overwhelming.

Also, there are some clocks which activate automatically. For example, if your WDT is active, it will force on a clock to use as its time base (likely the LSI clock).

There is a list of peripheral current consumption on page 61 of your linked datasheet.