Skip to content
Snippets Groups Projects
Commit 472026b2 authored by Edvin Åkerfeldt's avatar Edvin Åkerfeldt
Browse files

rtt_timing, E complete

parent 11863fb6
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,10 @@
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
# uncomment ONE of these three option to make `cargo run` start a GDB session
# which option to pick depends on your system
# runner = "arm-none-eabi-gdb -q -x openocd.gdb"
runner = "arm-none-eabi-gdb -q -x openocd.gdb"
# runner = "gdb-multiarch -q -x openocd.gdb"
# runner = "gdb -q -x openocd.gdb"
runner = "probe-run --chip STM32F411RETx"
# runner = "probe-run --chip STM32F411RETx"
rustflags = [
# This is needed if your flash or ram addresses are not aligned to 0x10000 in memory.x
......
......
......@@ -260,11 +260,42 @@ A/C = 4790151/40001 = 119,7507812 ~= 120
// https://developer.arm.com/documentation/ddi0439/b/Data-Watchpoint-and-Trace-Unit/DWT-Programmers-Model
//
// [Your answer here]
/*
The content of r1 is 0xE0001004. This is the address for the DWT_CYCCNT (Cycle count Register).
There are no functions call in the loop function because the compiler has optimized the instructions to just reading from the
cycle register and saving it in r0.
*/
//
// Now check your answer by dumping the registers
// (gdb) info registers
//
// [Register dump here]
/*
r0 0x80000000 -2147483648
r1 0xe0001004 -536866812
r2 0x2710 10000
r3 0xa 10
r4 0x20000000 536870912
r5 0x20000430 536871984
r6 0x0 0
r7 0x2000ffe8 536936424
r8 0x0 0
r9 0x0 0
r10 0x0 0
r11 0x0 0
r12 0x1 1
sp 0x2000ff98 0x2000ff98
lr 0x8000373 134218611
pc 0x800023e 0x800023e <rtt_timing::timed_loop+12>
xPSR 0x81000000 -2130706432
fpscr 0x0 0
msp 0x2000ff98 0x2000ff98
psp 0x0 0x0
primask 0x1 1
basepri 0x0 0
faultmask 0x0 0
control 0x0 0
*/
//
// We can now set a breakpoint exactly at the `nop`.
//
......@@ -290,6 +321,9 @@ A/C = 4790151/40001 = 119,7507812 ~= 120
// (gdb) x 0xe0001004
//
// [Your answer here]
/*
0xe0001004: 0xf73d58c8
*/
//
// Now, let's execute one iteration:
// (gdb) continue
......@@ -297,10 +331,16 @@ A/C = 4790151/40001 = 119,7507812 ~= 120
// What is now the current value of the cycle counter?
//
// [Your answer here]
/*
0xe0001004: 0xf73d58cc
*/
//
// By how much does the cycle counter increase for each iteration?
//
// [Your answer here]
/*
It increases by 4.
*/
//
// ------------------------------------------------------------------------
// F) Reseting the cycle counter
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment