I've got a board with a MS621 rechargeable backup battery. Some data should be kept in the memory after the device is powered-down.

Sometimes the battery will be discharged to a voltage below that which the STM32 backup registers require. In that case, I want to warn the user.

Therefore, I must measure the voltage of VBAT through the ADC of the STM32F1.

My question is that when STM32 is powered off (No VDD), will the connection between the battery and the ADC pin of the STM32 cause unexpected power consumption?

In other words, what's the state of the pin of the STM32 after the device is powered down? Will current drain from battery to the ADC pin of STM32?

Is there a better solution?

  • 1
    \$\begingroup\$ Can you please add a schematic regarding the power supply wiring of your mcu? \$\endgroup\$ – Bence Kaulics Sep 9 '16 at 6:40
  • \$\begingroup\$ Also please add the exact part number of your MCU, there are lot of from that series. \$\endgroup\$ – Bence Kaulics Sep 9 '16 at 7:36
  • \$\begingroup\$ @BenceKaulics I really don't think the exact part number matters, but he's almost certainly referring to the STM32F103C8 or one of its clones found on cheap blue pill boards. \$\endgroup\$ – Navin Jun 4 '19 at 6:14

Sadly the STM32F103 series does not offer an internal ADC channel connected to VBAT, so you have to connect it externally.

The problem arises as soon as you power off the microcontroller. If you were to connect the VBAT directly to another pin of the STM32 and turn off the main power supply, the protection diodes would start conducting and try to power the STM32. So it would lead to an excessive current draw on you backup domain.

A simple solution might be to put a large resistor in series.


simulate this circuit – Schematic created using CircuitLab

With this setup you limit the maximum current to be at most 3µA. It will be less, but predicting how much is a bit difficult.

Now measuring the battery with a 1MegOhm resistor is not the best idea, it's easy to get distortions and you have to be careful to select a long enough sampling rate to charge the sampling capacitor. So can we do better?

First thing which comes to mind is using an analog switch. Something like a TS5A3160 from Texas Instruments (there are lots of alternatives available, this will probably not be the best part available).

Now, as it is an IC, it will most likely be specified in a similar way than a microcontroller, that no input shall be above the supply rail. A look in the datasheet shows, that this is indeed the case. So we have to power it from the battery.

The supply current for this part is really low. Only a maximum of 100nA over the whole temperature range (careful which supply current condition you look at in the datasheet, I'm referring to the 3.3V pages). So that is no immediate downer.

Next thing we want to watch out for is leakage current of the inputs, which might be higher than the supply current in this case. It's a bit tricky to get which number we are looking at, so let me first explain how I'd wire the thing up:


simulate this circuit

As soon as you power down the microcontroller, the pulldown resistor will ensure that the analog switch flicks to the normally closed pin, which we tied to ground with another 100k resistor, so it doesn't float. In this state only the supply current and the leakage current of the NO-pin is draining the battery (and of course the VBAT domain of the STM32).

So the chip is powered and we are looking for the leakage current of the NO-pin. In the datasheet this corresponds to \$I_{NO(OFF)}\$ (and not \$I_{NO(PWROFF)}\$). And it turns out to be really low, a maximum of 50nA over the whole temperature range.

In the end we are looking at 150nA maximum, 12nA typical at 25°C additional drain from the battery with this analog switch. It provides a nice low impedance path to measure the voltage for the ADC. Compared to the 2.2µA maximum drawn by VBAT domain, this is not too heavy of an impact.

Downside is of course the added complexity on the board, you need another pin to switch the battery to the ADC and the costs. You can try and see what happens with the simple resistor solution, might work and be okay, but I wanted to show you an alternative.

  • 1
    \$\begingroup\$ Thanks a lot but this solution also costs too much. I've found a way that doesn't solve the problem perfectly but with lower cost. \$\endgroup\$ – user123179 Sep 10 '16 at 3:33

Accuracy in this design is not that important, 0.1V is enough.

enter image description here

The battery is charged through R1,voltage of the battery can be estimated by the voltage of the AD port.The voltage on the diode D1 in such a low current is about 300mV.

And I want to ask another question,forward voltage of IN4148 is too large so that the battery can not be charged fully(though a charge voltage of 3V provides about 90% of the capacity) .I want another diode with lower forward voltage. I've found IN5819 but the reverse current of it is really big. I wondered if there is a diode with a low forward voltage (less than 0.2V) and a low reverse current (less than 1uA in 3V). Thanks.


I do not know what exactly you are using STM, but try to use PVD module. www.st.com/resource/en/application_note/cd00164185.pdf Page 9.

PVD is dedicated to monitoring the supply voltage VDD and optimized for this job. No need any additional components. Everything is inside the chip. It is possible to generate an interrupt set by you, the threshold voltage.

  • \$\begingroup\$ This is potentially a solution to the problem, but you need to explain a bit what you're talking about for this to be a good answer. \$\endgroup\$ – pipe Sep 9 '16 at 5:46
  • \$\begingroup\$ Because they do not need any additional components or circuitry. Everything is connected inside the chip. You do not have to engage ADC to monitor the voltage VDD. \$\endgroup\$ – sigaris Sep 9 '16 at 5:51
  • \$\begingroup\$ Thanks but it doesn't solve the problem.There is not any EEPROM designed on the board which provide fast write access,and the capacitor isn't big enough to write the flash embedded in STM32.BTW,I used RTC module in this design,this also leads to the problem. \$\endgroup\$ – user123179 Sep 9 '16 at 6:11
  • \$\begingroup\$ I think design a internal ADC channel as what does to internal temperature sensor for VBAT monitoring will bring big improvement to STM.But unluckily they didn't,so I want to get a outer PCB design to solve the problem.Thanks. \$\endgroup\$ – user123179 Sep 9 '16 at 6:17
  • 1
    \$\begingroup\$ The question is about monitoring VBAT and not VDD. The PVD is not able to do this. \$\endgroup\$ – Arsenal Sep 9 '16 at 7:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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