8000 BCDAlarmTimeRegister does not support minutely on DS3231 · Issue #50 · adafruit/Adafruit_CircuitPython_Register · GitHub
[go: up one dir, main page]

Skip to content

BCDAlarmTimeRegister does not support minutely on DS3231 #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
caternuson opened this issue May 3, 2023 · 11 comments
Closed

BCDAlarmTimeRegister does not support minutely on DS3231 #50

caternuson opened this issue May 3, 2023 · 11 comments

Comments

@caternuson
Copy link
Contributor

More discussion here:
https://forums.adafruit.com/viewtopic.php?t=201104

The registers for Alarm 2 of the DS3231 do not have seconds:
alarm_reg

However, "minutely" (once per minute) triggering is supported:
alarm

@b-blake
Copy link
b-blake commented May 3, 2023

A short summary: alarm2 has minutes but they are not supported. alarm2 does not have seconds and justly are not supported. Changing line 172 of "i2c_bcd_alarm.py" to frequency < 1 fixes the issue. Status will need to be updated too.

@tekktrik
Copy link
Member
tekktrik commented May 4, 2023

Reading the forum, it looks like that line is (nearly) what the fix should be. Am I misunderstanding the issue?

@caternuson
Copy link
Contributor Author
caternuson commented May 4, 2023

I think there is more to be investigated.

It seems like there is a base assumption that supporting "minutely" requires seconds to be supported by the RTC:
adafruit/Adafruit_CircuitPython_PCF8523#2 (comment)

So that logic is correct based on that. But I do not know what drives that requirement.

If the DS3231's alarm2 is an odd ball, then maybe the answer is the DS3231 library can not use BCDAlarmTimeRegister?

@b-blake
Copy link
b-blake commented May 4, 2023

I am currently using minutely without problems from alarm2 on the DS3231 using the fix I have suggested. The part I can't find/fix is where in the other libraries "None" is reported when there is a status request of alarm2 on the DS3231 when minutely has been selected.

The PCF8523 mentioned above is a different chip which should have a different sub-function in the adafruit_register.py library. Limitations of the PCF8523 should not block functionality of the DS3231.

@b-blake
Copy link
b-blake commented May 4, 2023

I just looked at the data sheets on the PCF8523 and the DS3231. The internal registers do not match. e.g. The PCF8523 uses the first three registers for control where the DS3231 uses them for real time seconds, minutes, hours. The PCF8523 has only one alarm so how can it be a reason to limit the second alarm of the DS3231?

@b-blake
Copy link
b-blake commented May 4, 2023

I downloaded fresh all of the library from here and ran it. It still says minutley is not supported. Line 172 of i2c_bcd_alarm.py needs to read:
if frequency < 1 and not self.has_seconds:
not
if frequency <= 1 and not self.has_seconds:

@b-blake
Copy link
b-blake commented May 4, 2023

I found where the minutely vs None issue resides: It is lines 108 - 130. I am not sure what the change should be to follow the github rules, etc.

@b-blake
Copy link
b-blake commented May 5, 2023

This code addresses the issue of 'None' being displayed when 'minutely' is selected for alarm2. ~ Line 108
old Line 172 still needs to be changed to frequency < 1 and not self.has_seconds:
The added lines have the ########### marking them.

        frequency = None
        i = 1
        seconds = 0
        if self.has_seconds:
            if (self.buffer[1] & 0x80) != 0: # 0x80 no Seconds, else seconds
                frequency = "secondly" # = 0x80 NO seconds
            else:
                frequency = "minutely" # = 0x80 HAS seconds
                seconds = _bcd2bin(self.buffer[i] & 0x7F) # mask off 0x80
            i = 2
        else: ###############
            frequency = "minutely" ###############
            seconds = _bcd2bin(self.buffer[i] & 0x7F) ###############
        minute = 0

@mikeysklar
Copy link
Contributor

PR #57 includes @b-blake changes provided.

@tannewt
Copy link
Member
tannewt commented Sep 12, 2024

Fixed by #57

@tannewt tannewt closed this as completed Sep 12, 2024
@b-blake
Copy link
b-blake commented Sep 12, 2024

Thanks guys for all your help. Especially Mikey!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
0