DS3232 and battery backup.

Vmax

Member
I’ve added a DS3232 RTC (http://datasheets.maxim-ic.com/en/ds/DS3232.pdf) to my picaxe project , and everything’s working supper, except when removing power to the Vcc pin of the DS3232. When I put power back on this pin, the time goes back to midnight, January 1, 2001. I can’t get the battery backup working.:mad:

I’ve re-checked the circuit from battery to the Vbat pin and ground. I’ve even changed battery source. I can disconnect the PICAXE from the 5V+ source and the RTC works fine when reconnecting power to the PICAXE. The only thing I’m wondering about now is that I have two floating pins on the DS3232, the 32KHz pin, and the RST (i.e. reset) pin. I can't see why these would prevent battery backup.:confused:
 
Last edited:

cravenhaven

Senior Member
The datasheet specifically mentions that the RST pin should not be pulled high with an external resistor and the 32KHz pin is output only so shouldnt matter.
There is quite a discussion of the levels of VBat and VCC, what voltage are you using for VBat.
You could check that your VBat is working by monitoring the 32KHz output when VCC is removed (provided that it is enabled by BBSQW and INTCN).
 

Vmax

Member
Hi cravenhaven:

If the RST pin can't float, then it should be pulled high or low. I'll try low first.

I'm using a 3V Lithium for Vbat.

You could check that your VBat is working by monitoring the 32KHz output when VCC is removed (provided that it is enabled by BBSQW and INTCN).
I’m trying to set up the INT/SQW pin to output a 1 Hz square wave, and that signal is going to input Pin 2 of a 28X1.

hi2cout $0E, (%01000000)
hi2cout $0F, (%00000000)

I’m planning to interrupt the PICAXE twice a second from the DS3232 INT/SQW pin:

setint %00000100, %00000100

when the square wave is high, and

setint %00000000, %00000100

when the square wave is low.

I’ve also disabled the 32KHz output on the DS3232.
 

jtcurneal

Senior Member
It will not work if you pull the RST pin low. That will keep it in a reset condition.
The RST pin has an internal pull up resistor, You can leave it unconnected.

There is an internal memory bit at 0Eh bit 7 that may be set to 1
This bit disables the internal osc so there is less drain on the battery during shipping.

From the data sheet page 10.

" This mode can be used to minimize
battery requirements for times when maintaining
time and date information is not necessary, e.g., while
the end system is waiting to be shipped to a customer"

Joel
 

JoeFromOzarks

Senior Member
From the DS3232 datasheet:

(^RST ICPIN6) {RST Input/Output}

Page 9: "It has an internal 50k nominal value pullup resistor to VCC. No external pullup resistors should be connected."

Since it can be used to reset the PicAxe (i.e. ^RST is used as an OUTPUT) you really shouldn't tie it to ground either. You can leave the pin unconnected.

:) joe
 

Vmax

Member
I’ve tried moving the DS3232 power cap closer to the Vcc pin. No change in battery backup. The INT/SQW signal from the DS3232 to the Picaxe 28X1, input pin 2, goes from + to - but the signal is intermittent in the + phase of the square wave signal. Maybe a cap between INT/SQW pin and ground?

.
 

MartinM57

Moderator
I seem to recall having some problems with setting up a DS3232 - I also seem to recall that it was sorted by explicitly initialising all the registers at first ever startup, even though it looks like you don't have to. Some code (not PICAXE BASIC)...
Code:
//rtc_write (address, value)
rtc_write (0, 0x00);
rtc_write (1, 0x00);
rtc_write (2, 0x12);
rtc_write (3, 0x01);
rtc_write (4, 0x01);
rtc_write (5, 0x01);
rtc_write (6, 0x11);
rtc_write (7, 0x00);
rtc_write (8, 0x00);
rtc_write (9, 0x00);
rtc_write (10, 0x00);
rtc_write (11, 0x00);
rtc_write (12, 0x00);
rtc_write (13, 0x00);
rtc_write (14, 0x00);
 

Vmax

Member
Turns out it wasn’t a software issue, but only my poor design skills :eek:. I mounted the DS3232 on a DIY SOIC to DIP adapter. As luck would have it, one track on the adaptor was out of alignment with its pin, so I didn’t use it. Not a problem because it was pin 15 (GND). I just crossed pin 15 to 14, which goes to ground anyways. There was good resistance between pin 16 (Vbat) and pin 15, so I thought I was OK. Not the case. I managed to remove the unused track and battery backup now works! The unused track must have been interfering with how Vbat works. Lesson learned: next time don’t be so cheap and buy a proper SOIC to DIP adapter.

Everything seems to be working OK, even the INT/SQW pin is interrupting the PICAXE every ½ a second.
 

Vmax

Member
The interupt:

SYMBOL HalfSec = flag0 ; Unused bit on 28X1. Interrupt bit.
SYMBOL Sec = b10 ; Seconds
SYMBOL KeyTimer = b18 ; 1/2 second count timer.
SYMBOL Delay = b27 ; Seconds count down timer.

; setup i2c to DS3232 RTC chip

hi2csetup i2cmaster,%11010000, i2cslow, i2cbyte
pause 100

hi2cout $0E, (%00000000,%00000000)

; Interupt on DS3232 1Hz signal, pin 2.

setint %00000100,%00000100
HalfSec = 0

Main:

; Do something

goto Main

;---------
Interrupt:
;---------

HalfSec = HalfSec + 1 ; toggle halfsec flag
sec = sec + 1 - HalfSec ; skip every other 1/2 sec

if HalfSec = 1 then
setint %00000000,%00000100
else
setint %00000100,%00000100
endif

; Update Picaxe variables

if KeyTimer > 0 then
KeyTimer = KeyTimer - 1
endif

if Delay > 0 then
Delay = Delay - 1 + HalfSec
endif

return
 

fadishop

New Member
If not used the battery Vbat pin or terminal can not be left happily in the air. If instead of a capacitor battery does not, on occasion, you may lose settings stored in the SRAM. But if you use the battery should not place any capacitor and the leakage resistance of the capacitor would discharge the battery.

I love and work with DS3232. I maked a shield card for PICAXE system.

I made ​​different programs with PICAXE and DS3232.

Advertising deleted by eclectic
 
Top