Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
rtic_f4xx_nucleo
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
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Ruben Asplund
rtic_f4xx_nucleo
Commits
d87e6ea3
Commit
d87e6ea3
authored
4 years ago
by
Ruben Asplund
Browse files
Options
Downloads
Patches
Plain Diff
Exercise F
parent
fdf160ec
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/rtt_timing.rs
+24
-15
24 additions, 15 deletions
examples/rtt_timing.rs
with
24 additions
and
15 deletions
examples/rtt_timing.rs
+
24
−
15
View file @
d87e6ea3
//! examples/rtt_timing.rs
//! examples/rtt_timing.rs
#![deny(unsafe_code)]
//
#![deny(unsafe_code)]
#![deny(warnings)]
#![deny(warnings)]
#![no_main]
#![no_main]
#![no_std]
#![no_std]
use
cortex_m
::{
asm
,
peripheral
::
DWT
};
use
cortex_m
::{
asm
,
peripheral
::
DWT
};
use
panic_rtt_target
as
_
;
use
panic_halt
as
_
;
use
rtt_target
::{
rprintln
,
rtt_init_print
};
//use panic_rtt_target as _;
//use rtt_target::{rprintln, rtt_init_print};
use
stm32f4
;
use
stm32f4
;
#[rtic::app(device
=
stm32f4)]
#[rtic::app(device
=
stm32f4)]
const
APP
:
()
=
{
const
APP
:
()
=
{
#[init]
#[init]
fn
init
(
mut
cx
:
init
::
Context
)
{
fn
init
(
mut
cx
:
init
::
Context
)
{
rtt_init_print!
();
//
rtt_init_print!();
rprintln!
(
"init"
);
//
rprintln!("init");
// Initialize (enable) the monotonic timer (CYCCNT)
// Initialize (enable) the monotonic timer (CYCCNT)
cx
.core.DCB
.enable_trace
();
cx
.core.DCB
.enable_trace
();
cx
.core.DWT
.enable_cycle_counter
();
cx
.core.DWT
.enable_cycle_counter
();
rprintln!
(
"start timed_loop"
);
//rprintln!("start timed_loop");
let
(
start
,
end
)
=
timed_loop
();
//unsafe {
rprintln!
(
// cx.core.DWT.cyccnt.write(0);
"start {}, end {}, diff {}"
,
//}
start
,
end
,
let
(
_start
,
_end
)
=
timed_loop
();
end
.wrapping_sub
(
start
)
// rprintln!(
);
// "start {}, end {}, diff {}",
// start,
// end,
// end.wrapping_sub(start)
// );
}
}
#[idle]
#[idle]
fn
idle
(
_cx
:
idle
::
Context
)
->
!
{
fn
idle
(
_cx
:
idle
::
Context
)
->
!
{
rprintln!
(
"idle"
);
//
rprintln!("idle");
loop
{
loop
{
continue
;
continue
;
}
}
...
@@ -299,7 +304,7 @@ fn timed_loop() -> (u32, u32) {
...
@@ -299,7 +304,7 @@ fn timed_loop() -> (u32, u32) {
// What is the initial value of the cycle counter
// What is the initial value of the cycle counter
// (when hitting the `timed_loop` breakpoint)?
// (when hitting the `timed_loop` breakpoint)?
//
//
// [
Your answer here
]
// [
0x00000006
]
//
//
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// F) Finally some statics
// F) Finally some statics
...
@@ -340,6 +345,10 @@ fn timed_loop() -> (u32, u32) {
...
@@ -340,6 +345,10 @@ fn timed_loop() -> (u32, u32) {
// > cargo size --example rtt_timing --release --features nightly
// > cargo size --example rtt_timing --release --features nightly
//
//
// [Your answer here]
// [Your answer here]
// Compiling app v0.1.0 (/home/ruben/git/rtic_f4xx_nucleo)
// Finished release [optimized + debuginfo] target(s) in 0.44s
// text data bss dec hex filename
// 660 0 0 660 294 rtt_timing
//
//
// I was able to get down to:
// I was able to get down to:
// > cargo size --example rtt_timing --release --features nightly
// > cargo size --example rtt_timing --release --features nightly
...
...
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