adafruit / Adafruit-uRTC

MicroPython library for RTCs
MIT License
26 stars 8 forks source link

DS3231 alarms don't work: wrong bit mask applied in alarm setup #8

Closed miketeachman closed 5 years ago

miketeachman commented 5 years ago

I was having problems getting alarms to work for a DS3231 device

I debugged this module code and found that Bit 6 of the alarm day/date register is set incorrectly. According to the DS3231 datasheet, Bit 6 is set when day-of-the-week is used.

In this implementation Bit 6 is set for day-of-the-month, rather than for day-of-the-week.

The bug appears in the following line: https://github.com/adafruit/Adafruit-uRTC/blob/a8f7bed2ee6fb85f7d3f2e6c81d5059904ea7ffb/urtc.py#L168

Both alarms work when Bit 6 is set at the following line (and the set is removed at the previous line) https://github.com/adafruit/Adafruit-uRTC/blob/a8f7bed2ee6fb85f7d3f2e6c81d5059904ea7ffb/urtc.py#L170

both alarms work with this change

Thanks for all your MicroPython work!

kattni commented 5 years ago

Fixed by PR. We are deprecating this library. Please consider the many RTC libraries available in CircuitPython if you are looking for supported libraries. Please fork this repo if you wish to continue development.