Enable microsecond timing #245
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR enables microsecond timing, up from millisecond timing.
I've been working with timing in the 10ms range and it's a little odd to have only 1ms resolution when timing is slipping around. I'd like to increase the system clock resolution to microseconds to match FPrime's expectations.
Zephyr docs describe
k_uptime_ticks()asAdditionally I have been running with the
CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000000config setting for a few days on thedetumblebranch and anecdotally the system is less likely to experience a rate group slip.Example call added to the ADCS run handler:
Pre-change output:
Post-change output:
RP2350 Clock Capable of Microsecond Timing
The Zephyr system clock uses an external crystal oscillator running at$12MHz$ and is checked by the system clock running at $150MHz$ . We can see in the device tree that the crystal oscillator is defined as node
xoscand that the system clock (clk_sys) referencesxoscvia thepll_sysclock definition. We can validate this on the running system with:Where we see the output:
Given that the crystal oscillator is expected to run at$12MHz$ we know that we have $10^{-8}$ precision in the clock and this PR sets the tick precision within that range since microseconds are $10^{-6}$ .
References
k_uptime_get()Already Derived From TicksCalling
k_uptime_ticks()reduces the call stack when getting time because the call tok_uptime_get()derives millisecond timing return value fromk_uptime_ticks().Zephyr Microsecond Default
Zephyr defaults to$10000\ Ticks / s$ for most devices.
How Has This Been Tested?