mcauser / micropython-tinyrtc-i2c

MicroPython driver for TinyRTC I2C modules with DS1307 RTC and AT24C32N EEPROM
MIT License
61 stars 21 forks source link

DS1307 and HALT method #4

Open michalowskil opened 1 year ago

michalowskil commented 1 year ago

Not sure is it a bug or not. When I disconnect and then connect battery DS1307 is resetting to (2000, 1, 1, 0, 0, 0, 0, 0) which is fine, but it is not ticking. When I run ds.halt() it returns FALSE. Clock start ticking when I manually set FALSE like this: ds.halt(False).

Shouldn't ds.halt() return TRUE when clock is halted?

I'm not using a module. I just connect DS1307 with oscillator and resistors like this: scheme

mcauser commented 1 year ago

Needs further investigation. I don't have one of these modules handy for the next few weeks.

Expected behaviour: ds.halt() - return the current value (self._halt), without reading the register ds.halt(True) - read the DATETIME_REG register, set bit 7 = 1, write back to the register ds.halt(False) - read the DATETIME_REG register, set bit 7 = 0, write back to the register

If the default halt bit 7 value in the register is True, I should update the constructor to set self._halt = True, or perhaps just make the halt() method always read the register and not try to cache it.