Ds1307 backup battery not working - Page 1
Forum section: electronics / general

author: kgavionics
author_rank: Regular Contributor
timestamp: October 06, 2022, 01:10:35 pm
content: Hello guysI made a small board based on Ds1307 real time chip (see schematic below). This latter is connected to my stm32f407 which is working fine using the I2C protocol. I use the internal pull-ups by the way.My only problem is I can get the module to save time neither on a cr2032 coin battery nor a 2 AA (3.1). The datasheet suggest that the typical VBat is 3V.I build this module few years ago and as far as I remember, I didn't have any problem.I don't know why the Ds1307 not working even though I provide a stable battery voltage!Any help would be greatly appreciated !

author: Peabody
author_rank: Super Contributor
timestamp: October 06, 2022, 04:24:53 pm
content: Are you still supplying voltage at Vcc when you try to set the time? Maybe you need that for I2C to work. Just guessing.Edit: And it looks like you also need power at Vcc for SQW/OUT to work.

author: kgavionics
author_rank: Regular Contributor
timestamp: October 06, 2022, 05:42:43 pm
content: Quote from: Peabody on October 06, 2022, 04:24:53 pmWhen i set the time and date, the module is still on Vcc, afterwards, I remove it and it sould be powered by the battery, but in my case ,after I plugged back in, it shows the default time and date that I programmed!

author: Peabody
author_rank: Super Contributor
timestamp: October 06, 2022, 09:35:25 pm
content: Sorry, I don't have an explanation. If Vbat stays within the voltage range specified in the datasheet, it should continue to run the RTC unless there's a register setting of some kind that disables that behavior.

author: darkspr1te
author_rank: Frequent Contributor
timestamp: October 11, 2022, 06:11:02 am
content: Quote from: kgavionics on October 06, 2022, 01:10:35 pmI hope that PWR_FLAG goes to different pins on your MCU otherwise you are shorting your battery out.darkspr1te

author: TomS_
author_rank: Frequent Contributor
timestamp: October 11, 2022, 01:26:53 pm
content: Does the time increment while on vcc?

author: TomS_
author_rank: Frequent Contributor
timestamp: October 11, 2022, 01:28:50 pm
content: Quote from: darkspr1te on October 11, 2022, 06:11:02 amIt's a KiCad thing, not a net name, so they are not connected.

author: kgavionics
author_rank: Regular Contributor
timestamp: October 11, 2022, 06:06:57 pm
content: Quote from: TomS_ on October 11, 2022, 01:26:53 pmyes,the time and date are incrementing on VCC without any problem!

author: Peabody
author_rank: Super Contributor
timestamp: October 11, 2022, 10:54:17 pm
content: Is it possible your software or library is resetting the time? Could we see your code?

author: cv007
author_rank: Frequent Contributor
timestamp: October 11, 2022, 11:57:35 pm
content: QuoteUnconditionally setting the time on each boot is how it would get the 'programmed' time set. If power is lost, the time is reset and the CH bit in the seconds bit is set. With the CH bt set, the clock does not run.If you were actually losing power to the rtc, and you did not set its time on boot, the rtc would not be running. Reading the CH bit on boot would be a good way to tell whether the rtc has previously been set (so do not set again).

author: DavidAlfa
author_rank: Super Contributor
timestamp: October 12, 2022, 12:24:42 am
content: Could you attach a picture of the pcb showing the rtc part?Also, do you have scope?If so, try viewing the crystal signals with the probe, this often messes up the oscillator, so set the probe into 10x mode to reduce the load, if it works (Doesn't stop oscillating) then turn the rtc off and check if the clock keeps running.

author: TomS_
author_rank: Frequent Contributor
timestamp: October 12, 2022, 10:16:30 am
content: Quote from: kgavionics on October 11, 2022, 06:06:57 pmIf it loses power and resets to defaults I would expect it to come up as all zeroes or maybe some random time.But if it resets to a time that you have set in the past, are you sure this is not being reprogrammed by your code when the microcontroller gets powered again?