From d87e6ea365500ca03c707e4440bff0cf04f7a4b1 Mon Sep 17 00:00:00 2001 From: rubenasplund <ruben.asplund@hotmail.com> Date: Fri, 4 Dec 2020 18:47:32 +0100 Subject: [PATCH] Exercise F --- examples/rtt_timing.rs | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/examples/rtt_timing.rs b/examples/rtt_timing.rs index 55ec247..878fed2 100644 --- a/examples/rtt_timing.rs +++ b/examples/rtt_timing.rs @@ -1,39 +1,44 @@ //! examples/rtt_timing.rs -#![deny(unsafe_code)] +//#![deny(unsafe_code)] #![deny(warnings)] #![no_main] #![no_std] use cortex_m::{asm, peripheral::DWT}; -use panic_rtt_target as _; -use rtt_target::{rprintln, rtt_init_print}; +use panic_halt as _; +//use panic_rtt_target as _; +//use rtt_target::{rprintln, rtt_init_print}; use stm32f4; #[rtic::app(device = stm32f4)] const APP: () = { #[init] fn init(mut cx: init::Context) { - rtt_init_print!(); - rprintln!("init"); + //rtt_init_print!(); + //rprintln!("init"); // Initialize (enable) the monotonic timer (CYCCNT) cx.core.DCB.enable_trace(); cx.core.DWT.enable_cycle_counter(); - rprintln!("start timed_loop"); - let (start, end) = timed_loop(); - rprintln!( - "start {}, end {}, diff {}", - start, - end, - end.wrapping_sub(start) - ); + //rprintln!("start timed_loop"); + //unsafe { + // cx.core.DWT.cyccnt.write(0); + //} + + let (_start, _end) = timed_loop(); + // rprintln!( + // "start {}, end {}, diff {}", + // start, + // end, + // end.wrapping_sub(start) + // ); } #[idle] fn idle(_cx: idle::Context) -> ! { - rprintln!("idle"); + // rprintln!("idle"); loop { continue; } @@ -299,7 +304,7 @@ fn timed_loop() -> (u32, u32) { // What is the initial value of the cycle counter // (when hitting the `timed_loop` breakpoint)? // -// [Your answer here] +// [0x00000006] // // ------------------------------------------------------------------------ // F) Finally some statics @@ -340,6 +345,10 @@ fn timed_loop() -> (u32, u32) { // > cargo size --example rtt_timing --release --features nightly // // [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: // > cargo size --example rtt_timing --release --features nightly -- GitLab