Skip to content

Fix STM RTC read so it's atomic. #3545

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

Merged
merged 1 commit into from
Oct 13, 2020
Merged

Fix STM RTC read so it's atomic. #3545

merged 1 commit into from
Oct 13, 2020

Conversation

tannewt
Copy link
Member

@tannewt tannewt commented Oct 13, 2020

I turn off the shadow registers because 1) reading the SSR doesn't actually lock the other two (see the errata) and 2) the fallback is to read twice anyway. So, I might as well just read them twice because it'll be faster than waiting for the sync flag.

Fixes #3376

@tannewt tannewt added this to the 6.0.0 milestone Oct 13, 2020
@tannewt tannewt requested a review from jepler October 13, 2020 00:46
Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, see 2.2.3 in https://www.st.com/resource/en/errata_sheet/dm00037591-stm32f405-407xx-and-stm32f415-417xx-device-limitations-stmicroelectronics.pdf

This fix makes sense to me especially in light of the erratum. Assuming the test case originally supplied passes now (the one that sees time.monotonic going backwards), fine to merge. Thanks!

@tannewt
Copy link
Member Author

tannewt commented Oct 13, 2020

Assuming the test case originally supplied passes now (the one that sees time.monotonic going backwards), fine to merge.

Yup! I ran it for a while with no issues.

@tannewt tannewt merged commit 33dee4a into adafruit:main Oct 13, 2020
@FoamyGuy
Copy link
Collaborator

FoamyGuy commented Oct 13, 2020

I have not gotten the input/output error again running this build. So this does seem to solve that issue.

I've got the 33dee4a build from S3 installed on my Feather STM32F405 and I am seeing some odd behavior with time.sleep() taking longer than it should I think. I am running this code:

import time
for i in range(0,10):
    print(i)
    time.sleep(0.01)

This code is taking roughly 10 seconds to complete printing the numbers. At first I was thinking perhaps it's off by a factor of 10, but oddly enough if I tweak it to time.sleep(1) instead I am seeing pretty much the same behavior, no faster or slower than when I was sleeping for 0.01

If I use time.sleep(0.001) then everything will print very quickly, less than 1 second.

@tannewt
Copy link
Member Author

tannewt commented Oct 13, 2020

Thanks @FoamyGuy! I used time.monotonic to measure that it's taking 7 seconds to run...... looking into it now.

@tannewt
Copy link
Member Author

tannewt commented Oct 13, 2020

I think the sleep issue is fixed in #3549

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

Successfully merging this pull request may close these issues.

I2C bus error after while - OSError: [Errno 5] Input/output error
3 participants