diff --git a/.vscode/launch.json b/.vscode/launch.json index ec932b93fd374979e88b33e7a432da27a8c54e89..76129ae9fd2a480de24ae98b0f1f90a0e178d1a7 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 5ce0472bc834d9e7b1f11bd28f1f5f9d8bc81f9e..83a1f77bb55101e3dcaf5653bce5102892f34313 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 d8553401c61a9c14677578e887f55d825d85bbdd..851e21f45442061a59919d40e34f132788a0cbc0 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); } }