edit: Possibly resolved this, added edit at bottom.

I'm attempting to make a blue pill type device using a STM32L.

I have a STM32L152C8T6A and a QFP-48 breakout board. I have soldered the chip and have manage to connect and program it using CubeIDE. I'm using the low power modes and have confirmed in stop mode is using around 3uA. In run mode it is using around 900uA.

So far so good. But when attempting to add external crystals the power consumption is much higher, 100uA+ in stop mode. Which is more than a standard Blue Pill in stop mode.

I have tried separately adding a high speed 8Mhz and a low speed 32.768Khz external crystal and set the relevant pins in cubeIDE. While I can program it, the power consumption is way to high and also very jittery.

I'm using the nordic PPK2 to measure the power, by unplugging the debugger and powering it directly with that.

I have tried many different load capacitor values. 22pF, 8pF, no capacitors etc but they do not seem to make much difference.

Does the fact my PCB is plugged into breadboard with the crystals and capacitors just pushed in play a factor?

I did initially calculate the capacitor values, but have since tried many different values. In desperation I tried 0.1uF capacitors as load capacitors and the power consumption returned to normal, but I believe that is way too high.

I have looked at the schematic for the blue pill etc and I believe I have same schematic regarding the crystals.

Just looking for any advice if possible.

Update: Previously I was just enabling the crystals in cubeIDE in the main pin out overlay. I wasn't actually doing anything with the crystals. I thought this was enough to prove they are working. But I just enabled the RTC and selected the LSE source in the clock overlay and confirmed the code selects that.

And now it is working using the external 32.768 crystal with 22pF capacitors, and using around 4uA in stop mode.

So Think this was a misunderstanding on my part, but I'm not really sure why I was seeing the large consumption when the pins were set to the clock but not actually being used.

Update 2: A bit more testing confirms the above.

If you enable a crystal in 'System Core -> RCC -> LSE -> Crystal/ceramic Resonator'.

The pin overlay will update the pins to show it is connected, but if you do not use the crystal at all in the clock configuration screen your code will do nothing with those pins.

This is when the current usage will be high/jittery.

You can fix it by either using the crystal on the clock screen, or set the pins to GPIO_Analog if the crystal is already connected but you don't want to use it.


1 Answer 1


[...]but I'm not really sure why I was seeing the large consumption when the pins were set to the clock but not actually being used.

An oscillator circuit that's not oscillating is very often a simple arrangement of PMOS and NMOS transistors that look very much like a logic inverter gate... the only difference is that the oscillator adds a feedback resistor between input and output.


simulate this circuit – Schematic created using CircuitLab

The feedback resistor biases this logic gate at half-Vdd where there is significant shoot-through current. This shoot-through current flows from Vdd, through PMOS and NMOS transistors to GND (Vss) and is quite large - it may account for significant current that you measure in standby mode, especially if the oscillator is enabled, but not oscillating.
Be aware that once you add a crystal so that oscillation actually starts up, these transistors spend only a little time in the half-Vdd region where shoot-through current is maximum - and much more time near Vdd or near Vss as they swing up and down - oscillation actually causes average current to decrease.

The LSE oscillator at 32kHz likely uses tiny NMOS and PMOS transistors whose shoot-through current is far less than the HSE oscillator operating at much higher frequency. Shown below is an example of shoot-through current for 74HCU04 inverter from Philips data sheet...microcontroller oscillators use far lower-gain MOSfets that have much smaller shoot-through than this:

74HCU04 shoot-through current example graph

If your goal is lowest current drain, shut down any un-used oscillators (especially HSE), as well as any clocks for unused peripherals. If you can, use the internal microcontroller RC clock - it starts up far faster than a crystal oscillator, and likely doesn't suffer much from shoot-through. However, it is more jittery and has less frequency stability than crystal oscillators.
Pick your poison.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.