Sketch error changing from DS1307 > DS3231

I have recently added to my sketch a DS1307 RTC. I need to log data to an SD card with a time stamp. Everything seems to work as it should, but in reading on the web, it appears that for accuracy I should consider a DS3231 instead. To that end, I am attempting to make the required changes to the sketch. To the best of my knowledge (extremely limited at this point), I have the required library’s installed. When I try to compile the sketch I always end up with an error:

sketch_jan17a:285: error: 'class DS3232RTC' has no member named 'chipPresent'

     if (RTC.chipPresent())

             ^

The forum won’t allow me to post the sketch in it’s entirety as it exceeds “9000” characters…
I would appreciate any input on a possible solution.

Brian

(deleted)

What libraries are you using?

The Christensen DS3232RTC.h library does not implement the .chipPresent() method of the DS1307RTC.h

The .chipPresent() is an attempt to distinguish between the error resulting from a clock halt bit being set, and a Wire.endTransmission error with the DS1307 chip.

The DS3232/DS3231 does not implement the clock halt bit. For error testing, you can just read the return from .read() or .write().

cattledog:
What libraries are you using?

The Christensen DS3232RTC.h library does not implement the .chipPresent() method of the DS1307RTC.h

The .chipPresent() is an attempt to distinguish between the error resulting from a clock halt bit being set, and a Wire.endTransmission error with the DS1307 chip.

The DS3232/DS3231 does not implement the clock halt bit. For error testing, you can just read the return from .read() or .write().

Thanks!
Yes, I do have the Christensen Library installed...
For now, I have commented out the line giving me grief and the sketch now compiles correctly. I will read up further.

cattledog:
The DS3232/DS3231 does not implement the clock halt bit. For error testing, you can just read the return from .read() or .write().

The chip does have one. Maybe not the same bit.

Is it the EOSC/ (Enable Oscillator) bit of the Control Register of DS3231?

GolamMostafa:
Is it the EOSC/ (Enable Oscillator) bit of the Control register of DS3231?

Yes.

+1

Is it the EOSC/ (Enable Oscillator) bit of the Control Register of DS3231?

I think the DS1307 CH bit is better represented by the DS3231 Oscillator Stop Flag (OSF) in the status register (0Fh).

Status Register (0Fh)
Bit 7: Oscillator Stop Flag (OSF). A logic 1 in this bit indicates
that the oscillator either is stopped or was stopped
for some period and may be used to judge the validity of
the timekeeping data. This bit is set to logic 1 any time
that the oscillator stops. The following are examples of
conditions that can cause the OSF bit to be set:

  1. The first time power is applied.
  2. The voltages present on both VCC and VBAT are insufficient
    to support oscillation.
  3. The EOSC bit is turned off in battery-backed mode.
  4. External influences on the crystal (i.e., noise, leakage,
    etc.).
    This bit remains at logic 1 until written to logic 0.

Indeed there is a function in the Christensen DS3232 library which checks that flag.

*----------------------------------------------------------------------*
 * Checks the OSF bit in the status register which indicates that the   *
 * oscillator is or was stopped.                                        *
 *----------------------------------------------------------------------*/

boolean DS3232RTC::oscStopped(void)
{
    return ( readRTC(RTC_STATUS) & _BV(OSF) );
}

The EOSC bit is described as follows. It controls operation under battery power, and I do not think is set by error conditions.

Control Register (0Eh)
Bit 7: Enable Oscillator (EOSC). When set to logic 0,
the oscillator is started. When set to logic 1, the oscillator
is stopped when the DS3231 switches to VBAT. This bit
is clear (logic 0) when power is first applied. When the
DS3231 is powered by VCC, the oscillator is always on
regardless of the status of the EOSC bit. When EOSC is
disabled, all register data is static.

CH (Clock Halt) bit of DS1307 is a write-able Control Bit. It controls whether the clock oscillator circuit would be running or would remain stopped.

EOSC/ (Enable Oscillator) Bit of DS3231 is a write-able Control Bit. It controls whether the clock oscillator circuit would be running or would remain stopped.

OSF (Oscillator Stop Flag) of DS3231 is a read-able Status Bit. It's value is updated depending on the value of EOSC/ bit.

I added support for the EOSC in my RTC utility program so that I could save the soldered in batteries in modules I'm not using. But if you forget that you used it, it makes them look defective since other software doesn't attempt to check or clear it. It's not an issue with removable batteries, since the bit is cleared on initial power on.