diff --git a/compile.sh b/compile.sh index 96c2f2434948add79239513de39cadaa5075c5c3..3f27bdd10213f2dde1f4d0e9aa6565fca17d2a96 100755 --- a/compile.sh +++ b/compile.sh @@ -7,4 +7,5 @@ #cargo build --target thumbv7em-none-eabihf --release --example bare2 #cargo build --target thumbv7em-none-eabihf --example bare3 #cargo build --target thumbv7em-none-eabihf --example bare4 -cargo build --target thumbv7em-none-eabihf --example bare5 +#cargo build --target thumbv7em-none-eabihf --example bare5 +cargo build --target thumbv7em-none-eabihf --example bare6 diff --git a/examples/bare6.rs b/examples/bare6.rs index 0d06c1933dac6bd2df76335fcaed51acea7a243a..0e9e5a57a58d4c8333adc46042892a9fd1113f75 100644 --- a/examples/bare6.rs +++ b/examples/bare6.rs @@ -6,6 +6,7 @@ extern crate f4; extern crate stm32f40x; +extern crate cortex_m; #[macro_use] extern crate cortex_m_debug; @@ -76,7 +77,11 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) { // at 16 Mhz, 8000_0000 cycles = 0.5s // at 64 Mhz, 8000_0000 cycles = 0.125s + unsafe { + (*DWT.get()).cyccnt.write(0); + } loop { + ipln!("led on"); // set PA5 high, RM0368 8.4.7 gpioa.bsrr.write(|w| w.bs5().set_bit()); @@ -100,6 +105,10 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) { // vscode using the new "cortex debug" plugin // // what is the frequency of blinking +// +// >> Given that at 16Mhz, 8000_000 cycles = 0.5s, +// and we need to go 2*8000_000 cycles for the next light on, +// we're about ~1Hz on the blinking, just slightly above. // ** your answer here ** // // commit your answers (bare6_1) diff --git a/gdb.sh b/gdb.sh index e9c668178d5bdaaff0db227afb76c70c50cc2c27..672a140bd24551b96aedca874731efd9907a3790 100755 --- a/gdb.sh +++ b/gdb.sh @@ -8,4 +8,4 @@ TARGET=thumbv7em-none-eabihf #arm-none-eabi-gdb target/$TARGET/release/examples/bare2 #arm-none-eabi-gdb target/$TARGET/debug/examples/bare3 #arm-none-eabi-gdb target/$TARGET/debug/examples/bare4 -arm-none-eabi-gdb target/$TARGET/debug/examples/bare5 +arm-none-eabi-gdb target/$TARGET/debug/examples/bare6