DS3231 1Hz output timing profile

Continuing the discussion from DS3231 1hz sqw precision on vcc & on vbat:

Hello, I was looking for any information about how the falling/rising edges of DS3231 1Hz SQW output is related to seconds register update. Sadly I couldn't find any information on this in the DS3231 datasheet.

I can't exactly interpret the "roll over" expression in the quoted sentence , does it mean for example when seconds change from 15 to 16?

So at the exact moment when seconds register is updated (let's say that DS3231 internal time goes from 15:20:15 to 15:20:16), the SQW pin goes low (pull-up resistor is provided of course)?

Thanks in advance.

Yes, that is what I meant by rollover. Like an odometer. So it occurs in your example between 15.999999 (arbitrary number of 9s) and 16.000000 seconds.

It is not so explicitly described in the DS3231 data sheet. I saw another design using this and copied it for one of my own designs. However, it is described like this in the DS1307 data sheet and the DS3231 is supposed to be upwards compatible so that was good enough for me.

1 Like

The DS3231 datasheet also says:

"The countdown chain is reset whenever the seconds register
is written. Write transfers occur on the acknowledge from
the DS3231. Once the countdown chain is reset, to avoid
rollover issues the remaining time and date registers must
be written within 1 second. The 1Hz square-wave output, if
enabled, transitions high 500ms after the seconds data
transfer, provided the oscillator is already running."

I can't prove that the square wave falling edge coincides exactly with the start of a second, but if there is any separation, I think it is consistent.

Thanks for the update. It seems like it's behaving as you described. As I was playing around with alarm interrupt (with mcu sleep) and square wave output (when mcu is awake) I noticed something strange behavior, so I had to set up my scope, and I tried this little code (with 1Hz square wave output enabled):

while (1)
{
  unsigned long currentMillis = millis();
  if ((currentMillis - rtcReadMillis) >= 20ul)
  {
    dsRTC.read(rtcData);
    if (rtcData.Second != prevSec)
    {
      prevSec = rtcData.Second;
      digitalWrite(RED_LED_PIN, HIGH);
      delay(10);
      digitalWrite(RED_LED_PIN, LOW);
    }
    rtcReadMillis = currentMillis;
  }
}

The red led always went high after falling edge of square wave.

As the above picture shows, it is consistent, as you said.

BTW the main thing, why I took the trouble to hook up my scope is this (it also relates to the topic):

The red pulse is still when second is updated ("catched" by reading the RTC unreasonably frequent) and blue is the square-wave output.

If the 1Hz square wave is activated within 500ms after seconds register update, it can output shorter, than 500ms low pulse. First I thought it would be only driven low with the next seconds update (where it can be low for exactly 500ms).

A little off topic..

Anyone has an idea, what does "DS" supposed to stand for in DS3231 part number?

Dallas Semiconductor

Oh, okay, thanks.

Now I know the evolution. :smile:
Dallas Semiconductor --> Maxim Integrated --> Analog Devices

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.