I've been having a strange anomaly going on in a project using one of those small DS3231 modules like the below...
The way I use this module is simply for time of day. I read hours, minutes, and seconds consecutively in a typical I2C sequence where multiple registers are read. I do this about once every 2 seconds, since the project only needs accuracy to the minute. The problem seems to be that about once a month (which may be a clue), My I'll look at the time (displayed on an I2C LCD display) and I'll see that I've lost or gained an hour. (There is never an error in my minutes display). Thinking it was an I2C error that I was somehow missing, I modified the project to always read these time elements twice, and only believe it when I see hours and minutes equal in 2 successive reads. That didn't help.
Its a complex project, too long to post, and I'm aware of many possible ways I could have a coding error and will debug accordingly. But I thought it wouldn't hurt to ask:
- Could there be a simple procedural flaw in my dealing with this chip that could be causing this? For example, when I set the time I never set day of week, calendar day, year, or any alarm options. And as far as I know the only "configuration" I'm doing is to make sure I'm reading 24 hour time.
- Are there any known "bugs" or "gotcha's I've missed that could cause such hour read errors?
If not, I'll just keep snooping with debug outputs and hopefully isolate exactly what conditions seem to make this happen.