diff --git a/examples/timing_resources.rs b/examples/timing_resources.rs index 193d633c25673d5aec853c1fe62514c3592f39de..912d81530253b170a2ae28d9680a39609fdde389 100644 --- a/examples/timing_resources.rs +++ b/examples/timing_resources.rs @@ -72,6 +72,26 @@ const APP: () = { // Explain what is happening here in your own words. // // [Your code here] +/* +Tl;dr, +1. Saves privious basepri, and stops at our breakpoint +2. Loads our shared resource from memmory +3. Increment resource by 1 and save it back to memory +4. Changes back basepri to what it was before +5. Branches back to where we were before the exception. + +08000232 <EXTI0>: + 8000232: 40 f2 00 01 movw r1, #0 // Loads 0 into r1 + 8000236: ef f3 11 80 mrs r0, basepri // Save the current basepri into r0 + 800023a: 00 be bkpt #0 // Breakpoint here <-- Our interupt code begins here + 800023c: c2 f2 00 01 movt r1, #8192 // Puts 0x2000 into top 16-bits of r1 => 0x20000000 (The location of the shared resource, maybe also the begining of our memory) + 8000240: d1 e9 00 23 ldrd r2, r3, [r1]// Equivalent to: ldr r2, [r1]; ldr r3, [r1, #4], ie loads the bottom half of the shared resource into r2 and the top half into r3 + 8000244: 01 32 adds r2, #1 // Add 1 to r2, update flag (N, Z, C, V ie carry flags etc) <-- Increments our shared resource with 1 + 8000246: 43 f1 00 03 adc r3, r3, #0 // Add 0 to r3 (with carry) <-- Add the carry if we have carry from last operation + 800024a: c1 e9 00 23 strd r2, r3, [r1]// Saves back our shared resource into main memory <-- Our interupt code stops here + 800024e: 80 f3 11 88 msr basepri, r0 // Changes the basepri to what it was before + 8000252: 70 47 bx lr // Branches back to where we were before +*/ // // > cargo run --example timing_resources --release --features nightly // Then continue to the first breakpoint instruction: