Skip to content
Snippets Groups Projects
Commit 56004232 authored by Per Lindgren's avatar Per Lindgren
Browse files

cleanup of rtt-pwm

parent 34d1698f
Branches
No related tags found
No related merge requests found
//! examples/rtt_timing.rs
//! cargo run --examples rtt-pwm //! cargo run --examples rtt-pwm
#![deny(unsafe_code)] #![deny(unsafe_code)]
// #![deny(warnings)] #![deny(warnings)]
#![no_main] #![no_main]
#![no_std] #![no_std]
use cortex_m::{asm, peripheral::DWT};
use panic_halt as _; use panic_halt as _;
use rtt_target::{rprintln, rtt_init_print}; use rtt_target::{rprintln, rtt_init_print};
use stm32f4xx_hal::{dma, gpio::Speed, prelude::*, pwm, stm32}; use stm32f4xx_hal::{gpio::Speed, prelude::*, pwm};
#[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true)] #[rtic::app(device = stm32f4xx_hal::stm32, peripherals = true)]
const APP: () = { const APP: () = {
#[init] #[init]
fn init(mut cx: init::Context) { fn init(cx: init::Context) {
rtt_init_print!(); rtt_init_print!();
rprintln!("init"); rprintln!("init");
let dp = cx.device; let dp = cx.device;
// Initialize (enable) the monotonic timer (CYCCNT)
cx.core.DCB.enable_trace();
cx.core.DWT.enable_cycle_counter();
// Set up the system clock. 16 MHz? // Set up the system clock. 16 MHz?
let rcc = dp.RCC.constrain(); let rcc = dp.RCC.constrain();
let clocks = rcc.cfgr.freeze(); let clocks = rcc.cfgr.freeze();
...@@ -39,10 +33,8 @@ const APP: () = { ...@@ -39,10 +33,8 @@ const APP: () = {
rprintln!("max_duty {}", max_duty); rprintln!("max_duty {}", max_duty);
ch1.set_duty(max_duty / 2); ch1.set_duty(max_duty / 2);
ch1.enable(); ch1.enable();
ch2.set_duty((max_duty * 1) / 2); ch2.set_duty((max_duty * 1) / 3);
ch2.enable(); ch2.enable();
} }
#[idle] #[idle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment