8000 esp8266: Improved time keeping by Adam5Wu · Pull Request #2728 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

esp8266: Improved time keeping #2728

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
wants to merge 3 commits into from
Closed

esp8266: Improved time keeping #2728

wants to merge 3 commits into from

Conversation

Adam5Wu
Copy link
@Adam5Wu Adam5Wu commented Dec 27, 2016
  1. use more stable system clock as general time source;
  2. increase rtc accuracy and reduce drifts.

@Adam5Wu
Copy link
Author
Adam5Wu commented Dec 27, 2016

Problem reference: #2724

offset+= clk_ticks-clk_last_ticks;
} else {
// If overflow happened, assume 1 wrap-around and persist info for the new cycle
offset+= clk_ticks+~clk_last_ticks+1;
Copy link
Member

Choose a reason for hiding this comment

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

Did you see that there is system_time_high_word already defined elsewhere which handles overflow? See mp_hal_ticks_ms() for example. It would be good to reuse this counter, then probably you don't need esp_clk_XXX functions.

Copy link
Author

Choose a reason for hiding this comment

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

I saw that one. However, I think that variable is for slightly different purposes.
The "system clock" is designed to be adjustable, i.e. if for any reason a program wants to adjust current system time, the "offset" will be amended accordingly;
The system_time_high_word is for tracking the time differences between two ref points, and adjusting system clock should not affect this counter, otherwise the result will be wrong after adjusting the system clock.

Copy link
Author
@Adam5Wu Adam5Wu Jan 5, 2017

Choose a reason for hiding this comment

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

I have made a new revision, which reuses system_time_high_word for time keeping, and just maintain an offset of "time between 2000 and last reboot" for system clock.

This does not eliminate the esp_clk_... functions, but made them a lot simpler. :D

return offset;
};

void pyb_rtc_set_us_since_2000(uint64_t nowus) {
Copy link
Member

Choose a reason for hiding this comment

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

Please don't (unnecessarily) move the definition of these functions, it makes it hard to see exactly how they changed.

Copy link
Author
@Adam5Wu Adam5Wu Dec 29, 2016

Choose a reason for hiding this comment

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

I have moved the pyb_rtc... functions here because I would like to use the set function in mp_hal_rtc_init(), and I think having the definition before use make code reading a little easier. :)
The new pyb_rtc_... function are completely rewritten, so they have little relation to the old code. Their code logic are more like the esp_clk_... functions.

mp_obj_get_int(items[5]),
mp_obj_get_int(items[6])) * 1000 + mp_obj_get_int(items[7])) * 1000);
uint64_t arg_us = ((uint64_t)timeutils_seconds_since_2000(
mp_obj_get_int(items[0]),
Copy link
Member

Choose a reason for hiding this comment

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

Please keep original indentation of the lines that don't change.

nubcore added a commit to nubcore/micropython that referenced this pull request Jan 12, 2017
@jcea
Copy link
Contributor
jcea commented Mar 15, 2017

Any news about integration of this PR?.

@pfalcon
Copy link
Contributor
pfalcon commented Mar 15, 2017

This PR changes more things than needed, so it's hard even to review, so nobody did that so far (in full). Beyond that, it needs a lot of testing, because otherwise it may turn out that it fixes one thing and break others. So @jcea, if you've done an extended testing of this patch, please report details of it (what exactly was tested, how, for how long, etc.).

@pfalcon
Copy link
Contributor
pfalcon commented Mar 15, 2017

Oh, and there're still code style issues. (Which always rings a bell - if there're errors is such a simple and visible matter as punctuation, what more complex, less visible errors the code may contain?)

@Adam5Wu
Copy link
Author
Adam5Wu commented Mar 16, 2017

@pfalcon, I think by saying "punctuation" style issue, you really meant to say "indentation", as already fixed in eb0ad96? Or could you please be more specific on the "punctuation" you are referring to?

Also, would you care to point out what unecessary code is involved in your opinion?

Without specifics, it is hard to follow your hand-waving arguments to the conclusion you made.

Or maybe your conclusion is simply infallible:
Yes, to err is to human, so who knows what can go wrong, I didn't check so anything is possible

@Adam5Wu
Copy link
Author
Adam5Wu commented Mar 16, 2017

Oh well, this is getting absurd.

For the record, I have switched to Arduino esp8266 months ago, because I found the current uP implementation for esp8266 cannot meet my expectation of usability and stability. I decided to give it more time to mature before I venture back again.

I kept my fork and PRs with the good will of at least save other people's effort and time I have spent on solving these problems. But clearly, it has become more of an eyesore to some maintainers.

So, one less problem for you, one less problem for me. :P

@Adam5Wu Adam5Wu closed this Mar 16, 2017
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Mar 25, 2020
Update ports/nrf/common-hal/busio/UART.c to include MIDI baud rate of 32150
@PvdBerg1998
Copy link

Closing this PR is very unfortunate as I'm hitting the same issue for a time critical application. @pfalcon is this PR still applicable?

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

Successfully merging this pull request may close these issues.

5 participants
0