2
\$\begingroup\$

I'm designing a circuit with STM32F407 and a DS3231 chip clock. The MCU has a separate VBat pin that can be used and on the other hand, the DS3231 chip has its own RTC. I'm wondering can I use a single RTC battery for both circuits? I found some circuits that suggest using a common Schottky diode like bat54c before connecting the battery to MCU. Should I use it too or not? Thanks.

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

This is perfect example of XY Problem.

Without studying the datasheets you've made several incorrect assumptions and decided to use external RTC, which created new power supply problem for you. Here are the assumptions:

  • The DS3231 is more accurate.

The DS3231 accuracy is ±2 ppm. The basic accuracy of STM32F407 is 5 ppm. However it also has digital calibration feature that allows you to output clock to external pin for measurement and subsequent calibration in 0.95 ppm steps.

So, the achievable accuracy of MCU RTC is 2 times better than external RTC.

  • The power consumption is less with external RTC.

DS3231 consumes 110 µA in standby mode. STM32F407 requires only 4 µA in standby mode with SRAM backup or 3.3 µA without backup. Note, that even if you use external interrupt to wake up MCU, both of them will be consuming power in standby.

So, the power consumption with DS3231 is 33 times more than with internal RTC only.

  • MCU can not calculate Date Time directly.

Here is a quote from the datasheet: "Two 32-bit registers contain the seconds, minutes, hours (12- or 24-hour format), day (day of week), date (day of month), month, and year. Compensations for 28-, 29- (leap year), 30-, and 31-day months are performed automatically." Not only that, but it also can be programmed for Daylight Saving Time compensation, something that DS3231 cannot do.

So, RTC in STM32F407 can do everything DS3231 does, and more.

To summarize, there is no need whatsoever to use DS3231 with STM32F407.

Having said that, there is a way to reduce power consumption even more, by using nano-power external timer, like TPL5110 to switch MCU power supply OFF completely. In this case (called VBAT mode) the RTC will continue running, consuming only 0.96 µA from backup battery. The timer itself adds negligible 35 nA, for total consumption under 1 µA (3 µA savings, compared to standby mode).

\$\endgroup\$
10
  • 1
    \$\begingroup\$ I think you might want to consider the strength with which you are making this argument. Calibrating the STM32's RTC to within 2ppm is not trivial. You'll need a good frequency counter (expensive) and, in production, equipment that will need regular calibration/checking. Implementing temperature compensation is even more complicated (you'll need a temp chamber and precision freq counter to characterize the crystal you've picked) and the STM32 cannot do any compensation when it is running off the backup battery. \$\endgroup\$
    – Jon
    Commented Oct 10, 2018 at 12:51
  • 1
    \$\begingroup\$ @Jon Even without calibration we are talking about the difference between 2 ppm and 5 ppm. Considering how many MCUs are happily running with 10~50 ppm crystals I'd say using 110 µA external RTC is a bit counterproductive, don't you think? Especially with precise nano-power clock chips (without calendar) available on the market. Note, that my argument was about DS3231, not RTC chips in general \$\endgroup\$
    – Maple
    Commented Oct 10, 2018 at 13:35
  • \$\begingroup\$ @Maple Thanks. But I have one question, If my MCU lost power, I mean supply power (like a LiPo battery), does it still keep the time? As I tested DS3231 can run with a single coin for 6 months or so. \$\endgroup\$ Commented Oct 11, 2018 at 6:55
  • \$\begingroup\$ @MasoudR. That is what "VBAT mode" is. When Vdd disconnected RTC continues to run from backup battery. The last paragraph describes how you can use this to minimize battery consumption, by supplying Vdd through MOSFET controlled by external timer. The TPL5110 timer + MCU RTC use 100 times less power than DS3231. You can calculate how long this setup will run from the same battery, \$\endgroup\$
    – Maple
    Commented Oct 11, 2018 at 14:02
  • \$\begingroup\$ @Maple Thank you very much. But how can I use the tlp5110? I mean I can connect it to MCU VDD pin to switch it completely off. In my project sleep timers are varies, it may take 1 hour or 7 weeks and in tlp5110 I think I can only set fixed timers right? For example, how can I tell tlp5110 to wake the MCU for next 1 hour? \$\endgroup\$ Commented Oct 12, 2018 at 7:07
1
\$\begingroup\$

I think you can use the same battery for both.

Vbat = 1.65 to 3.6V for the STM32F407

so a 3V Li coin cell would work.

At the same time, why do you need the external RTC (DS3231)? What is it providing that the STM32F407 cannot?

2.2.20 VBAT operation

The VBAT pin allows to power the device VBAT domain from an external battery, an external supercapacitor, or from VDD when no external battery and an external supercapacitor are present.

BAT operation is activated when VDD is not present. The VBAT pin supplies the RTC, the backup registers and the backup SRAM.

\$\endgroup\$
5
  • \$\begingroup\$ DS3231 is more accurate \$\endgroup\$
    – Indraneel
    Commented Oct 9, 2018 at 15:57
  • \$\begingroup\$ @CrossRoads Thanks. Actually, I'm not sure if the MCU can calculate DateTime directly, I think it would require to do some programming and btw I need the RTC for MCU to only wake it up on certain durations not using for calculating time. \$\endgroup\$ Commented Oct 9, 2018 at 16:01
  • \$\begingroup\$ @MasoudR. then you don't need to connect battery to MCU at all. RTC can provide all necessary wake up events with its alarm support. \$\endgroup\$
    – Maple
    Commented Oct 9, 2018 at 17:30
  • \$\begingroup\$ @Maple So you mean I should connect the interrupt pin of DS3231 to a digital input of MCU and then wake it up by external by setting interrupt, right? Is there any other difference with using its internal RTC? \$\endgroup\$ Commented Oct 10, 2018 at 6:07
  • \$\begingroup\$ @MasoudR. That was the idea, yes. However after looking at the datasheets this does not seem to be much better. There is not enough space in comments, so I created another answer. Note, that this one is still a valid answer to your original question, as posted. \$\endgroup\$
    – Maple
    Commented Oct 10, 2018 at 12:32

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.