diff --git a/examples/rtt_timing.rs b/examples/rtt_timing.rs index 4ee67756ac0d8fceb17692d8701abfa5df55fba9..1dc033c21753525cf2ba4db6c7d82f0cca97a9a1 100644 --- a/examples/rtt_timing.rs +++ b/examples/rtt_timing.rs @@ -45,7 +45,7 @@ const APP: () = { #[no_mangle] fn timed_loop() -> (u32, u32) { let start = DWT::get_cycle_count(); - for _ in 0..10000 { + for _ in 0..1000 { asm::nop(); } let end = DWT::get_cycle_count(); @@ -63,15 +63,15 @@ fn timed_loop() -> (u32, u32) { // A.1) What is the cycle count for the loop? // > cargo run --example rtt_timing // -// [Your answer here] +// [The loop in timed_loop is looping 335424926-330634772 = 4790154 times] // // A.2) How many cycles per iteration? // -// [Your answer here] +// [4790154/1000 = 4790] // // A.3) Why do we need a wrapping subtraction? // -// [Your answer here] +// [Becasue the variable is a unsigned 32 bit int, which will overflow when taking substraction bit wise. Therefore a wrapper is there to make sure the substraction is correctly calculated even if it overflow.] // // ------------------------------------------------------------------------ // Now try a release (optimized build, see `Cargo.toml` for build options).