Skip to content
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

Setting day of week in the RTC can both disable the battery and set the wrong day #249

Closed
tomxp411 opened this issue Dec 31, 2023 · 0 comments · Fixed by #273
Closed

Setting day of week in the RTC can both disable the battery and set the wrong day #249

tomxp411 opened this issue Dec 31, 2023 · 0 comments · Fixed by #273
Labels
bug Something isn't working

Comments

@tomxp411
Copy link
Contributor

https://cx16forum.com/forum/viewtopic.php?p=30971

The KERNAL call clock_set_date_time (Which in is the file rtc.s and called rtc_set_date_time) has a bug in the section that sets the day of week. After it sets the battery enable bit with ora $08, it calls i2c_write_byte_as_bcd. In doing so, depending on which day of week you were trying to set, it can set the wrong day of week, and if the bin_to_bcd conversion (In the same file.) resets the battery enable bit in the BCD conversion, it will disable the battery.

Changing the i2c_write_byte_as_bcd call to i2c_write_byte fixes it. It was never needed to do the BCD conversion as the legal data is never over 7, attempting to do the bcd conversion IF the battery enable bit PLUS the day of week results in a BCD value over 9 it will create 2 BCD digits, with the low order one wrong and the battery enable bit not set.

@mooinglemur mooinglemur added the bug Something isn't working label Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants