Conversation
LeStarch
left a comment
There was a problem hiding this comment.
A note about why this will take a lot of testing to qualify.
|
|
||
| #### System Clock Configuration #### | ||
| # Run system clock at 1 MHz for microsecond precision timing | ||
| CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000000 |
There was a problem hiding this comment.
This change will have a massive effect on the system. It will change interrupt timings, thread switching timings, and any other timings defined by the system. It will also increase overhead of kernel operations (context switching, etc) because these will happen more often.
Ticks represent the minimum time quantum that the kernel can detect and act on. We currently use 10000. This increases that value by 100x.
There was a problem hiding this comment.
Ah, thank you for this clarification. I thought the objection was around changing the Zephyr call from k_uptime_get() to k_uptime_ticks(). Agreed this is worth looking into.
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?