Useful status register in Maxim RTC chips: OSF

308 views
Skip to first unread message

Paolo Cravero

unread,
Jul 26, 2017, 11:56:00 AM7/26/17
to neoni...@googlegroups.com
Hello everyone.
While trying to figure out something new for a clock I'm building (including firmware), I spent some time reading all chapters of Maxim's DS3231 RTC chip datasheet. So I met a useful and often forgotten register (from ds3231 datasheet):

Control/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,  leak-age, etc.).
This bit remains at logic 1 until written to logic 0

Most Arduino libraries do not handle it but it can provide useful information in case there's something wrong with the i2c clock data. Not too precise but at least you have a hint to start troubleshooting from the RTC. 

I would reset OSF every time the user sets the time and read its status periodically. Then display something unusual if it is set. 

The tubes I am using have both decimal points, so they can be used to display something useful.

Now that I think of it, having 4 Nixies therefore 8 decimal points, I can display binary data too!

I hope I was not the only one not using this flag :) (amongst those clock builders that do not use GPS or NTP).
Paolo


gregebert

unread,
Jul 26, 2017, 1:01:25 PM7/26/17
to neonixie-l
I used it on my wristwatch project for awhile, before I had the ability to set the time.
The FPGA code set the time to 8PM (the earliest time I can sneak into my workshop during the workweek) when this bit was set, then cleared it.
All I had to do was remove the battery and short-out the supply (the DS3231 has internal parasitic capacitance that retains state for more than a few seconds). Then the time was accurately set.

In case you have not already found out, there is a good reason why Maxim calls this device "Extremely Accurate".
After more than 2 years, mine is still within about 10 seconds of the correct time. That's about 0.1PPM.
Reply all
Reply to author
Forward
0 new messages