Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RIOT
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
cm-projects
RIOT
Commits
7b083f19
Commit
7b083f19
authored
9 years ago
by
Andreas "Paul" Pauli
Browse files
Options
Downloads
Plain Diff
Merge pull request #4918 from gebart/pr/xtimer-drift-jitter
tests/xtimer_drift: Compute drift and jitter
parents
df184e3b
ed0cb746
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/xtimer_drift/main.c
+19
-8
19 additions, 8 deletions
tests/xtimer_drift/main.c
with
19 additions
and
8 deletions
tests/xtimer_drift/main.c
+
19
−
8
View file @
7b083f19
...
...
@@ -87,8 +87,9 @@ void *slacker_thread(void *arg)
void
*
worker_thread
(
void
*
arg
)
{
(
void
)
arg
;
u
nsigned
in
t
loop_counter
=
0
;
u
int32_
t
loop_counter
=
0
;
uint32_t
start
=
0
;
uint32_t
last
=
0
;
printf
(
"Starting thread %"
PRIkernel_pid
"
\n
"
,
thread_getpid
());
...
...
@@ -98,19 +99,26 @@ void *worker_thread(void *arg)
uint32_t
now
=
xtimer_now
();
if
(
start
==
0
)
{
start
=
now
;
last
=
start
;
++
loop_counter
;
continue
;
}
uint32_t
us
,
sec
;
u
nsigned
in
t
min
,
hr
;
us
=
now
%
1000000
;
sec
=
now
/
1000000
;
u
int32_
t
min
,
hr
;
us
=
now
%
SEC_IN_USEC
;
sec
=
now
/
SEC_IN_USEC
;
min
=
(
sec
/
60
)
%
60
;
hr
=
sec
/
3600
;
if
((
loop_counter
%
TEST_HZ
)
==
0
)
{
uint32_t
expected
=
start
+
loop_counter
*
TEST_INTERVAL
;
int32_t
diff
=
now
-
expected
;
printf
(
"now=%"
PRIu32
".%06"
PRIu32
" (%u hours %u min), diff=%"
PRId32
"
\n
"
,
sec
,
us
,
hr
,
min
,
diff
);
int32_t
drift
=
now
-
expected
;
expected
=
last
+
TEST_HZ
*
TEST_INTERVAL
;
int32_t
jitter
=
now
-
expected
;
printf
(
"now=%"
PRIu32
".%06"
PRIu32
" (%"
PRIu32
" hours %"
PRIu32
" min), "
,
sec
,
us
,
hr
,
min
);
printf
(
"drift=%"
PRId32
" us, jitter=%"
PRId32
" us
\n
"
,
drift
,
jitter
);
last
=
now
;
}
++
loop_counter
;
}
...
...
@@ -124,11 +132,14 @@ int main(void)
puts
(
"Make note of the PC clock when starting this test, let run for a while, "
"compare the printed time against the expected time from the PC clock."
);
puts
(
"The difference is the RIOT timer drift, this is likely caused by either: "
"
I
naccurate hardware timer, or bugs in the software (xtimer or periph/timer)."
);
"
an i
naccurate hardware timer, or bugs in the software (xtimer or periph/timer)."
);
printf
(
"This test will run a periodic timer every %lu microseconds (%lu Hz), "
,
(
unsigned
long
)
TEST_INTERVAL
,
(
unsigned
long
)
TEST_HZ
);
puts
(
"The current time will be printed once per second, along with the "
"difference between the actual and expected xtimer_now value."
);
puts
(
"The first output variable, 'drift', represents the total offset since "
"start between xtimer_now and the expected time."
);
puts
(
"The second output variable, 'jitter', represents the difference in drift from the last printout."
);
puts
(
"Two other threads are also running only to cause extra interrupts and context switches."
);
puts
(
" <====== PC clock if running in pyterm."
);
puts
(
""
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment