Discharging the battery for the FSE clock

Post here first, or if you can't find a relevant section!
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Discharging the battery for the FSE clock

Post by ChPr »

Hello everyone,

With a STM32F103C8T6, I use the FSE clock with a CR2032 battery connected to the VB terminal to know the date and time. The battery is practically new and the measurement indicates 3 V. It works well.

To check the battery voltage, I use an analogRead(PA0). This works well too.

However, after a night when I cut the power supply to the STM32, when I switched it back on, the voltage of the CR2032 battery had dropped to 2V.

Could this be linked to the fact that the PA0 input was drawing current while the STM32 was not powered?

If so, is there a way to avoid this problem?

Is it also possible to measure this voltage by reading a register or similar, without having to connect the VB terminal to another STM32 input?

Best regards.

Pierre.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

FSE clock?

Is there a current for VBAT-pin in datasheet? 1,4 µA ... not really low.
µA - not mA
Last edited by STM32ardui on Fri Jul 12, 2024 3:27 pm, edited 1 time in total.
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

STM32ardui wrote: Fri Jul 12, 2024 1:21 pm FSE clock? ...
Sorry, I meant LSE.
STM32ardui wrote: Fri Jul 12, 2024 1:21 pm ... Is there a current for VBAT-pin in datasheet? 1,4 mA ... not really low.
IDD_VBAT.jpg
IDD_VBAT.jpg (47.16 KiB) Viewed 4618 times
They're more like µA, right?

SIncerely.

Pierre
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

Sorry, mistyping. Of course 1,4 µA (not mA).

Modern MCUs have 150 - 600 nA.
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Discharging the battery for the FSE clock

Post by ag123 »

apparently, there are some defective stm32f103 distributed out in the flea markets
I've got a stm32f103 that drains a cr2032 running VBAT in a few days !
(actually I think some board makers did not check if there could be shorts on their boards)
then the next one it last more than a year, my guess is the current draw is in the 1s to low 100 (max) of microamps
the RTC goes on so well I practically 'forget' about it
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

The STM32 I use was purchased on 23/02/2018. That's 6 years !

When the STM32 is not powered, by placing a 10 k resistor in series with the CR2032, I measured, using an oscilloscope connected to the resistor terminals, a current of 12 µA to which is added a current of 1.8 µA if I connect the PA0 input to the Vbat terminal.

The current in Vbat seems high. The current in the PA0 input remains low. Still, not enough to discharge a battery overnight. I'll measure again with a really new battery.

Anyway. Is there a way to measure the Vbat voltage via registers without connecting the PA0 pin to the Vbat pin ?

Best regards.

Pierre.
STM32ardui
Posts: 142
Joined: Mon May 06, 2024 1:46 pm
Answers: 1
Location: Germany

Re: Discharging the battery for the FSE clock

Post by STM32ardui »

I don't really understand, what you want to do ...

When power is off, core is off and RAM content is gone.
By VBAT only RTC, LSE crystal/oszillator and some registers in the RTC-domaine should work.


Why do you want to measure voltage of battery?
As long as VDD is present, VBAT is disconnected. So during normal operation, battery can't be drained. With your connection to PA0 you have a current all the time.
What's about a super capacitor large enough to retain RTC during power-off cycles?

And you should buy another board from a reliable source to compare currents.
Or a board with a more modern MCU.
BTW: measuring a current by resistor and oszilloskop? :roll:

ChPr wrote: Sat Jul 13, 2024 9:25 am Anyway. Is there a way to measure the Vbat voltage via registers without connecting the PA0 pin to the Vbat pin ?
You can look inside Reference Manual.
There you find a description of each register. :mrgreen:

Before you waste your time:
Do you remember this graphic from datasheet?
power supply scheme.jpg
power supply scheme.jpg (89.48 KiB) Viewed 4513 times
During normal operation VBAT-pin is disconnected.
How can core measure something without connection?
ag123
Posts: 1898
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: Discharging the battery for the FSE clock

Post by ag123 »

ChPr wrote: Sat Jul 13, 2024 9:25 am The STM32 I use was purchased on 23/02/2018. That's 6 years !

When the STM32 is not powered, by placing a 10 k resistor in series with the CR2032, I measured, using an oscilloscope connected to the resistor terminals, a current of 12 µA to which is added a current of 1.8 µA if I connect the PA0 input to the Vbat terminal.

The current in Vbat seems high. The current in the PA0 input remains low. Still, not enough to discharge a battery overnight. I'll measure again with a really new battery.

Anyway. Is there a way to measure the Vbat voltage via registers without connecting the PA0 pin to the Vbat pin ?

Best regards.

Pierre.
well try a different stm32, like mentioned there are various possibilities
- possible shorts on the pcb, normally that will measure high currents or low ohms
- possible shorts or component problems elsewhere e.g. the 32k crystal, the caps etc
- possible defective stm32
I've seen for myself a big difference simply changing a 'bluepill' , 'maple mini' (I patched a 32k crystal manually) stm32f103 board
one board drains a cr2032 running VBAT in a few days
the other last a year and beyond
i.e. given a non defective stm32 and there are no other component problems / shorts etc, it'd seemed quite likely you get what is in the specs
the on soc RTC on LSI 32k crystal runs for months and months and is a reliable RTC clock
it is as good as an average pc RTC clock

and of course VBAT should not be connected to anything else if you want to drive that from a coin cell
and VBAT for what is worth only keeps the 32k crystal the LSI oscillator and RTC and backup domain a few registers 'alive'
the whole chips is practically shutdown and all the memory is *lost*, nothing is kept in sram, when you restart, sram is empty
if you need anything e.g. gpio, even for that input or any pheriperials or even sram for that matter, that is the job of VDD the main power source.
and if you need that you need to provide power to keep it VDD alive.
ChPr
Posts: 25
Joined: Thu Jun 20, 2024 8:03 am
Answers: 1

Re: Discharging the battery for the FSE clock

Post by ChPr »

Thank you "STM32ardui" and "ag123" for your comments. Indeed, I can see that I have no interest in draining the battery when, in normal mode, it is not connected.

So I'm going to abandon the battery monitoring that I wanted to do. I'll measure the voltage at its terminals from time to time (maybe every year ;) ).

Sincerely.

Pierre.
ozcar
Posts: 176
Joined: Wed Apr 29, 2020 9:07 pm
Answers: 5

Re: Discharging the battery for the FSE clock

Post by ozcar »

If you have a spare ADC capable GPIO, maybe you could connect VBAT to that and then periodically enable the pull-down (to give it some load) and then read the voltage.

This is not something I have done though.
Post Reply

Return to “General discussion”