From b67b9d32f71a5fc98e2be448a096e5b9175155f2 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 17 Sep 2024 10:52:43 +0200 Subject: [PATCH] update VS Code config --- README.md | 6 ++-- examples/simple/examples/timer-ticks.rs | 11 +++++-- va416xx-hal/src/timer.rs | 2 +- vscode/launch.json | 41 +++++++++---------------- vscode/tasks.json | 26 ++++++++++++++++ 5 files changed, 54 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 1b55377..d4a2352 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,8 @@ example. ### Using VS Code Assuming a working debug connection to your VA108xx board, you can debug using VS Code with -the [`Cortex-Debug` plugin](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug). +the [`Cortex-Debug` plugin](https://marketplace.visualstudio.com/items?itemName=marus25.cortex-debug). Please make aure that [`objdump-multiarch` and `nm-multiarch`](https://forums.raspberrypi.com/viewtopic.php?t=333146) +are installed as well. Some sample configuration files for VS code were provided and can be used by running `cp -rT vscode .vscode` like specified above. After that, you can use `Run and Debug` @@ -111,4 +112,5 @@ configuration variables in your `settings.json`: - `"cortex-debug.gdbPath.osx"` The provided VS Code configurations also provide an integrated RTT logger, which you can access -via the terminal at `RTT Ch:0 console`. +via the terminal at `RTT Ch:0 console`. In order for the RTT block address detection to +work properly, `objdump-multiarch` and `nm-multiarch` need to be installed. diff --git a/examples/simple/examples/timer-ticks.rs b/examples/simple/examples/timer-ticks.rs index ffa7821..6da3f8e 100644 --- a/examples/simple/examples/timer-ticks.rs +++ b/examples/simple/examples/timer-ticks.rs @@ -3,9 +3,9 @@ #![no_std] use core::cell::Cell; +use cortex_m::asm; use cortex_m_rt::entry; use critical_section::Mutex; -use embedded_hal::delay::DelayNs; use panic_rtt_target as _; use rtt_target::{rprintln, rtt_init_print}; use simple_examples::peb1; @@ -36,10 +36,11 @@ fn main() -> ! { .xtal_n_clk_with_src_freq(peb1::EXTCLK_FREQ) .freeze(&mut dp.sysconfig) .unwrap(); - let mut delay_provider = set_up_ms_tick(&mut dp.sysconfig, dp.tim0, &clocks); + let _ = set_up_ms_tick(&mut dp.sysconfig, dp.tim0, &clocks); let mut second_timer = CountdownTimer::new(&mut dp.sysconfig, dp.tim1, &clocks); second_timer.start(1.Hz()); second_timer.listen(); + // let delay_provider = dp.sy loop { let current_ms = critical_section::with(|cs| MS_COUNTER.borrow(cs).get()); if current_ms - last_ms >= 1000 { @@ -48,7 +49,11 @@ fn main() -> ! { let second = critical_section::with(|cs| SEC_COUNTER.borrow(cs).get()); rprintln!("Second counter: {}", second); } - delay_provider.delay_ms(1000); + for _ in 0..30000 { + asm::nop(); + } + + //delay_provider.delay_ms(1000); } } diff --git a/va416xx-hal/src/timer.rs b/va416xx-hal/src/timer.rs index 82feb39..c6710a4 100644 --- a/va416xx-hal/src/timer.rs +++ b/va416xx-hal/src/timer.rs @@ -587,7 +587,7 @@ impl CountdownTimer { pub fn load(&mut self, timeout: impl Into) { self.tim.reg().ctrl().modify(|_, w| w.enable().clear_bit()); self.curr_freq = timeout.into(); - self.rst_val = self.clock.raw() / self.curr_freq.raw() - 1; + self.rst_val = (self.clock.raw() / self.curr_freq.raw()) - 1; self.set_reload(self.rst_val); // Decrementing counter, to set the reset value. self.set_count(0); diff --git a/vscode/launch.json b/vscode/launch.json index e7ba243..f583000 100644 --- a/vscode/launch.json +++ b/vscode/launch.json @@ -74,8 +74,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -104,8 +103,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -134,8 +132,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -164,11 +161,11 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, + "timestamp": true, "type": "console" } ] @@ -194,8 +191,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -224,8 +220,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -255,8 +250,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -286,8 +280,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -317,8 +310,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -348,8 +340,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8004", + "address": "auto", "decoders": [ { "port": 0, @@ -379,8 +370,7 @@ "runToEntryPoint": "main", "rttConfig": { "enabled": true, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff8000", + "address": "auto", "decoders": [ { "port": 0, @@ -409,9 +399,8 @@ "interface": "swd", "runToEntryPoint": "main", "rttConfig": { - "enabled": false, - // Have to use exact address unfortunately. "auto" does not work for some reason.. - "address": "0x1fff806c", + "enabled": true, + "address": "auto", "decoders": [ { "port": 0, @@ -422,4 +411,4 @@ } }, ] -} \ No newline at end of file +} diff --git a/vscode/tasks.json b/vscode/tasks.json index a141443..cf2752f 100644 --- a/vscode/tasks.json +++ b/vscode/tasks.json @@ -55,6 +55,19 @@ "kind": "build", } }, + { + "label": "timer-ticks-example", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": [ + "build", + "--example", + "timer-ticks" + ], + "group": { + "kind": "build", + } + }, { "label": "blinky-example", "type": "shell", @@ -160,5 +173,18 @@ "kind": "build", } }, + { + "label": "embassy-example", + "type": "shell", + "command": "~/.cargo/bin/cargo", // note: full path to the cargo + "args": [ + "build", + "--bin", + "embassy-example" + ], + "group": { + "kind": "build", + } + }, ] } \ No newline at end of file