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

DA1469x: Clock time shifts on reboots #3321

Merged
merged 6 commits into from
Oct 29, 2024

Conversation

apc067
Copy link
Contributor

@apc067 apc067 commented Oct 17, 2024

If the LP clock's frequency is not an integer multiple of the specified OS tick frequency, the period of OS ticks will be incorrect due to integer division truncation errors (to the tune of almost 1% for RCX), resulting in OS Time
gradually creeping away from the actual time. This PR fixes the issue, by maintaining the fractional OS tick value and advance OS Time accordingly.

This PR also improves on the implementation of the DA1469x clock driver and updates the RTC divider registers after the selected LP clock is calibrated.

Copy link
Contributor

@kasjer kasjer left a comment

Choose a reason for hiding this comment

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

Number of functions are moved around that makes it harder to see what is new and what was really modified/added.

hw/mcu/dialog/da1469x/include/mcu/da1469x_clock.h Outdated Show resolved Hide resolved
hw/hal/include/hal/hal_os_tick.h Outdated Show resolved Hide resolved
hw/hal/include/hal/hal_system.h Outdated Show resolved Hide resolved
@apc067
Copy link
Contributor Author

apc067 commented Oct 22, 2024

Number of functions are moved around that makes it harder to see what is new and what was really modified/added.

I see your concern; I separated the original commit into two, one only rearranges the functions with no changes whatsoever, and the second one adds the missing services to the API.

@kasjer
Copy link
Contributor

kasjer commented Oct 22, 2024

If your first commit does not change functionality is it really needed?

Copy link
Contributor

@andrzej-kaczmarek andrzej-kaczmarek left a comment

Choose a reason for hiding this comment

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

Please don't move code around in .c files - this breaks git annotate

hw/mcu/dialog/da1469x/src/da1469x_clock.c Outdated Show resolved Hide resolved
hw/mcu/dialog/da1469x/src/da1469x_lpclk.c Outdated Show resolved Hide resolved
hw/mcu/dialog/da1469x/src/da1469x_clock.c Outdated Show resolved Hide resolved
hw/mcu/dialog/da1469x/src/da1469x_clock.c Outdated Show resolved Hide resolved
hw/hal/include/hal/hal_os_tick.h Outdated Show resolved Hide resolved
@apc067
Copy link
Contributor Author

apc067 commented Oct 22, 2024

Please don't move code around in .c files - this breaks git annotate

Yeah, keeping the git annotate may indeed outweigh the benefits of having the functions in a neat order. To that extent, should I keep the "da1469x/clock: Eliminate magic numbers" commit, or should I leave those lines unchanged as well?

@andrzej-kaczmarek
Copy link
Contributor

Please don't move code around in .c files - this breaks git annotate

Yeah, keeping the git annotate may indeed outweigh the benefits of having the functions in a neat order. To that extent, should I keep the "da1469x/clock: Eliminate magic numbers" commit, or should I leave those lines unchanged as well?

Keep it, removing magic numbers is fine.

@apc067 apc067 force-pushed the peterc/DA1469x-clock-update branch from 0d38224 to 561a02b Compare October 26, 2024 00:28
@github-actions github-actions bot added size/m and removed size/l labels Oct 26, 2024
@apc067
Copy link
Contributor Author

apc067 commented Oct 26, 2024

Addressed all current reviewer comments.

Copy link
Contributor

@vrahane vrahane left a comment

Choose a reason for hiding this comment

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

I tested it. Seems to be working great. Once all the comments are addressed, we can merge it in.

Copy link
Contributor

@andrzej-kaczmarek andrzej-kaczmarek left a comment

Choose a reason for hiding this comment

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

one issue left, otherwise lgtm.

please also fix coding style to pass CI

hw/mcu/dialog/da1469x/src/da1469x_clock.c Outdated Show resolved Hide resolved
@sjanc
Copy link
Contributor

sjanc commented Oct 29, 2024

yeap, looks ok after this typo and minor coding style is fixed:)
Thanks!

@apc067 apc067 force-pushed the peterc/DA1469x-clock-update branch from ae37693 to 781489b Compare October 29, 2024 18:47
This commit adds the missing services to the driver API. It also makes the
actual calibration of the XTAL32K clock a syscfg option, defaulting to 0.
This commit replaces the magic numbers with meaningfully named constants.
This commit streamlines the LP clock API, by offering clean access to the
LP clock selected via sysconfig.
This commit adds the function that calculates the RTC divider registers, and
invokes it when the LP clock frequency changes.
@apc067 apc067 force-pushed the peterc/DA1469x-clock-update branch from 781489b to c4e9455 Compare October 29, 2024 18:54
If the LP clock's frequency is not an integer multiple of the specified OS tick
frequency, the period of OS ticks will be incorrect due to an integer division
truncation error (to the tune of almost 1% for RCX), resulting in OS Time
gradually creeping away from the actual time. This commit fixes the issue, by
maintaining the fractional OS tick value and advance OS Time accordingly.
This commit adds masking to register bitfields, where a wrong syscfg value
may result in the inadvertent overrides of neighboring bitfields.
@apc067 apc067 force-pushed the peterc/DA1469x-clock-update branch from c4e9455 to f0cc564 Compare October 29, 2024 21:09
@vrahane vrahane merged commit 64e8e16 into apache:master Oct 29, 2024
19 checks passed
@apc067 apc067 deleted the peterc/DA1469x-clock-update branch October 30, 2024 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants