From ccddbada68cb3daedb67354135a2392751d2e421 Mon Sep 17 00:00:00 2001 From: Per <Per Lindgren> Date: Tue, 13 Feb 2018 11:42:35 +0100 Subject: [PATCH] example using new "cortex debug" plugin, built in ITM dump, works with both 16 and 64Mhz (simplified launch script, now builds all examples) --- .vscode/launch.json | 43 ++++++++++++--- .vscode/tasks.json | 128 ++------------------------------------------ examples/bare6.rs | 8 +-- 3 files changed, 44 insertions(+), 135 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index ec932b9..76129ae 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -355,11 +355,38 @@ "interface/stlink.cfg", "target/stm32f4x.cfg" ], - "cwd": "${workspaceRoot}", + "postLaunchCommands": [ + "monitor arm semihosting enable" + ], + "swoConfig": { + "enabled": true, + "cpuFrequency": 16000000, + "swoFrequency": 2000000, + "source": "probe", + "decoders": [ + { + "type": "console", + "label": "Name", + "port": 0 + } + ] + }, + "cwd": "${workspaceRoot}" + }, + { + "type": "cortex-debug", + "request": "launch", + "servertype": "openocd", + "name": "c bare6 16Mhz", + "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6", + "configFiles": [ + "interface/stlink.cfg", + "target/stm32f4x.cfg" + ], "swoConfig": { "enabled": true, "cpuFrequency": 16000000, - "swoFrequency": 1000000, + "swoFrequency": 2000000, // you may try 1000000 if not working "source": "probe", "decoders": [ { @@ -368,26 +395,26 @@ "port": 0 } ] - } + }, + "cwd": "${workspaceRoot}" }, { "type": "cortex-debug", "request": "launch", "servertype": "openocd", - "name": "c bare6", + "name": "c bare6 64Mhz", "executable": "./target/thumbv7em-none-eabihf/debug/examples/bare6", "configFiles": [ "interface/stlink.cfg", "target/stm32f4x.cfg" ], "postLaunchCommands": [ - "monitor tpiu config internal /tmp/itm.log uart off 16000000", - "monitor itm port 0 on" + "monitor reset init" ], "swoConfig": { "enabled": true, - "cpuFrequency": 16000000, - "swoFrequency": 1000000, + "cpuFrequency": 64000000, + "swoFrequency": 2000000, // you may try 1000000 if not working "source": "probe", "decoders": [ { diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 5ce0472..83a1f77 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,8 +5,8 @@ "tasks": [ { "type": "shell", - "label": "xargo build", - "command": "xargo build", + "label": "xargo build --examples", + "command": "xargo build --examples", "problemMatcher": [ "$rustc" ], @@ -17,128 +17,8 @@ }, { "type": "shell", - "label": "xargo build --release", - "command": "xargo build --release", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example loop", - "command": "xargo build --example loop", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example gpio", - "command": "xargo build --example gpio", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example gpio_raw", - "command": "xargo build --example gpio_raw", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare0", - "command": "xargo build --example bare0", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare1", - "command": "xargo build --example bare1", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare2", - "command": "xargo build --example bare2", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare3", - "command": "xargo build --example bare3", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare4", - "command": "xargo build --example bare4", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare5", - "command": "xargo build --example bare5", - "problemMatcher": [ - "$rustc" - ], - "group": { - "kind": "build", - "isDefault": true - } - }, - { - "type": "shell", - "label": "xargo build --example bare6", - "command": "xargo build --example bare6", + "label": "xargo build --examples --release", + "command": "xargo build --examples --release", "problemMatcher": [ "$rustc" ], diff --git a/examples/bare6.rs b/examples/bare6.rs index d855340..851e21f 100644 --- a/examples/bare6.rs +++ b/examples/bare6.rs @@ -39,15 +39,17 @@ fn idle(dwt: &mut DWT, rcc: &mut RCC, gpioa: &mut GPIOA) { // configure PA5 as output, RM0368 8.4.1 gpioa.moder.modify(|_, w| w.moder5().bits(1)); + // at 16 Mhz, 8000_0000 cycles = 0.5s + // at 64 Mhz, 8000_0000 cycles = 0.125s loop { ipln!("led on"); // set PA5 high, RM0368 8.4.7 gpioa.bsrr.write(|w| w.bs5().set_bit()); - wait_cycles(dwt, 10_000); + wait_cycles(dwt, 8000_000); - ipln!("idle off"); + ipln!("led off"); // set PA5 low, RM0368 8.4.7 gpioa.bsrr.write(|w| w.br5().set_bit()); - wait_cycles(dwt, 10_000); + wait_cycles(dwt, 8000_000); } } -- GitLab