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

pwm dma wip3

parent ebc494e6
Branches
No related tags found
No related merge requests found
...@@ -20,7 +20,7 @@ panic-halt = "0.2.0" ...@@ -20,7 +20,7 @@ panic-halt = "0.2.0"
#panic-itm = "0.4.2" #panic-itm = "0.4.2"
# Uncomment for the rtt-timing example. # Uncomment for the rtt-timing example.
#panic-rtt-target = { version = "0.1.1", features = ["cortex-m"] } panic-rtt-target = { version = "0.1.1", features = ["cortex-m"] }
# Uncomment for the panic example. # Uncomment for the panic example.
#panic-semihosting = "0.5.6" #panic-semihosting = "0.5.6"
......
...@@ -46,18 +46,22 @@ const APP: () = { ...@@ -46,18 +46,22 @@ const APP: () = {
// At this point it has been contrained into SysConf and used to set clocks // At this point it has been contrained into SysConf and used to set clocks
let rcc = unsafe { &(*stm32::RCC::ptr()) }; let rcc = unsafe { &(*stm32::RCC::ptr()) };
// pwm_all_channels!(TIM1: (tim1, apb2enr, apb2rstr, 0u8, pclk2, ppre2)); // // pwm_all_channels!(TIM1: (tim1, apb2enr, apb2rstr, 0u8, pclk2, ppre2));
// Enable and reset the timer peripheral, // // Enable and reset the timer peripheral,
// it's the same bit position for both registers (0 in this case) // // it's the same bit position for both registers (0 in this case)
// Notice the use of bit banding to set/clear bits individually // // Notice the use of bit banding to set/clear bits individually
// It is unsafe, as the register address could be anything within range // // It is unsafe, as the register address could be anything within range
// of the bitband region // // of the bitband region
unsafe { // unsafe {
bb::set(&rcc.apb2enr, 0u8); // bb::set(&rcc.apb2enr, 0u8);
bb::set(&rcc.apb2rstr, 0u8); // bb::set(&rcc.apb2rstr, 0u8);
bb::clear(&rcc.apb2rstr, 0u8); // bb::clear(&rcc.apb2rstr, 0u8);
} // }
rcc.apb2enr.modify(|_, w| w.tim1en().set_bit());
rcc.apb2rstr.modify(|_, w| w.tim1rst().set_bit());
rcc.apb2rstr.modify(|_, w| w.tim1rst().clear_bit());
// Setup chanel 1 and 2 as pwm_mode1 // Setup chanel 1 and 2 as pwm_mode1
tim1.ccmr1_output() tim1.ccmr1_output()
.modify(|_, w| w.oc1pe().set_bit().oc1m().pwm_mode1()); .modify(|_, w| w.oc1pe().set_bit().oc1m().pwm_mode1());
...@@ -120,18 +124,18 @@ const APP: () = { ...@@ -120,18 +124,18 @@ const APP: () = {
tim1.dier.write(|w| w.uie().enabled()); tim1.dier.write(|w| w.uie().enabled());
loop { // loop {
for i in 0..255 { // for i in 0..255 {
tim1.ccr1.write(|w| unsafe { w.ccr().bits(i) }); // tim1.ccr1.write(|w| unsafe { w.ccr().bits(i) });
tim1.ccr2.write(|w| unsafe { w.ccr().bits(i) }); // tim1.ccr2.write(|w| unsafe { w.ccr().bits(i) });
// rprintln!("-"); // // rprintln!("-");
//while tim1.sr.read().uif().is_clear() { // //while tim1.sr.read().uif().is_clear() {
while !tim1.sr.read().uif().is_clear() { // while !tim1.sr.read().uif().is_clear() {
rprintln!("-"); // rprintln!("-");
} // }
// rprintln!("!"); // // rprintln!("!");
} // }
} // }
} }
#[idle] #[idle]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment