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

Add support to set the clock rate and have sntp use it. #3236

Merged
merged 2 commits into from
Aug 8, 2020

Conversation

pjsg
Copy link
Member

@pjsg pjsg commented Aug 1, 2020

Fixes #3235

  • This PR is for the dev branch rather than for master.
  • This PR is compliant with the other contributing guidelines as well (if not, please describe why).
  • I have thoroughly tested my contribution.
  • The code changes are reflected in the documentation at docs/*.

This just adds support to rtctime.set to allow it to be used with the first two args as nil. In this case, if the rate is supplied as argument 3, then it is set.

The sntp module also initializes the clock PLL from the current rate.

@@ -139,8 +139,10 @@ It is highly recommended that the timestamp is obtained via NTP (see [SNTP modul

Values very close to the epoch are not supported. This is a side effect of keeping the memory requirements as low as possible. Considering that it's no longer 1970, this is not considered a problem.

You specify the seconds parameter with the optional microseconds (defaults to 0). Setting the rate is independant.
Copy link
Member

Choose a reason for hiding this comment

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

Generally speaking, docs don't use 2nd person like this. Separately, that's remarkably terse. How about "Times are specified across two arguments, seconds and microseconds. If microseconds are not specified, the default is 0 (i.e., time is exactly at the boundary between two seconds). In addition to the time, a third argument specifies the local clock's drift rate estimate, as documented in rtctime.get(). If this argument is not given or is nil, the current rate estimate will not be altered, and the rate estimate may be set without changing the time by leaving the seconds and microseconds arguments nil."

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

As a side note -- this is the rate of a WEMOS D1 MINI over almost 24 hours:

image

I suspect that differences are temperature related caused by localized heating due to the amount of work being done by the CPU. I'm going to try modifying a board to use a TCXO instead and see what happens.

@nwf
Copy link
Member

nwf commented Aug 2, 2020

Delightful. I had done something similar for #2819 and hadn't cleaved it out as its own PR.

@marcelstoer marcelstoer added this to the Next release milestone Aug 3, 2020
@nwf
Copy link
Member

nwf commented Aug 3, 2020

I'm happy for this to land.

@marcelstoer marcelstoer merged commit 995114b into nodemcu:dev Aug 8, 2020
vsky279 pushed a commit to vsky279/nodemcu-firmware that referenced this pull request Nov 21, 2020
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.

3 participants